עבור לתוכן
View in the app

A better way to browse. Learn more.

HWzone

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

javascript לא מאכלס את שדה select

Featured Replies

פורסם

שלום.

יש לי את העמוד הזה (נוצר כתוצאה סופית של קוד PHP):





<!DOCTYPE HTML>
<html>
<head>
<title>
TorahForMe.org
</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="he-IL" />
<script>
function populate_cat() {
document.getElementById("sel_cat").options[0]=new Option("Bible", "1", true, false);document.getElementById("sel_cat").options[1]=new Option("Gemarah", "2", false, false);document.getElementById("sel_cat").options[2]=new Option("Halacha", "3", false, false);document.getElementById("sel_cat").options[3]=new Option("Hebrew", "4", false, false);}

function populate_sub() {
document.getElementById("sel_sub").options.length=0;
cat = document.getElementById("sel_cat").value;
switch(cat){
case 1:document.getElementById("sel_sub").options[0] = new Option("Genesis", "1", true, false);document.getElementById("sel_sub").options[1] = new Option("Daniel", "5", false, false);break;case 2:document.getElementById("sel_sub").options[0] = new Option("Kidushim", "4", true, false);document.getElementById("sel_sub").options[1] = new Option("Ta'anit", "6", false, false);break;case 3:document.getElementById("sel_sub").options[0] = new Option("Rif", "3", true, false);break;case 4:document.getElementById("sel_sub").options[0] = new Option("Q and A", "2", true, false); break;
}
}
</script> </head>
<body onload="populate_cat()">

<div style="border: 0px solid black; clear: both; background-color: black; color: white; width: 100%; padding: 2px;">
Welcome, Admin<style>
.topmenu a:link{color: white; text-decoration: none; }
.topmenu a:visited {color: white; text-decoration: none; }
.topmenu a:hover{color: white; text-decoration: underline;}
</style>
<span style="float:right" class="topmenu">
<a href="#">
Change Password
</a>
  |  
<a href="auth.php?log=out">
Log Out
</a>

</span> </div>

<div style=" vertical-align:top; float: left; border: 0px solid black; width: 200px; padding: 0px;">
<div style=" vertical-align:top; float: left; border: 0px solid black; width: 200px; padding: 5px; background-color:#eeeeee; margin-top: 5px;">
<!--MENU-->
<a href="edit_m.php">
Edit Podcast's Menu
</a>
<br />
Edit Podcast's
<!--MENU-->
</div>
</div>

<div style="margin-left:220px; border: 0px solid black; padding: 5px; ">
<form name="get_menu" id="get_menu">
<select name="sel_cat" id="sel_cat" onchange="populate_sub()">

</select>
<select name="sel_sub" id="sel_sub">

</select>
</form>
</div>
</body>
</html>

שאני לא מצליח להבין למה כשאני משנה את השדה sel_cat לא מתבצע איכלוס של השדה sel_sub. ביזבזתי על הבעיה הזאת לפחות שעה וחצי וזה מתסכל בטירוף.

תודה מראש לעוזרים.

פורסם

הערך של select.value הוא מחרוזת (string) ולא מספר.

אתה צריך לעשות גרשיים מסביב למספר בcase:

switch(cat){
case "1":
etc;
}

פורסם
  • מחבר

תודה זה עובד מצוין עכשיו.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.