עבור לתוכן
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.

הסתרה והצגה של תיבות select

Featured Replies

פורסם

בוקר טוב, אני מנסה לכתוב סקריפט פשוט שיעבוד תחת IE ו FIREFOX, סקריפט שתפקידו להציג תיבות select נסתרות בהתאם לבחירה בתיבת select ראשית.

הנה הקוד שבנתיים כתבתי :

    
<form action="view.php" method="post" name="details">
<script language="JavaScript">
function clear_selected() {
document.getElementById("man").style.display="none";
document.getElementById("scale").style.display="none";
document.getElementById("man").value='';
document.getElementById("scale").value='';
}

function all_changed() {
switch(document.getElementById("all").value){
case '0':
document.getElementById("man").style.display="none";
document.getElementById("scale").style.display="none";
document.getElementById("man").value='';
document.getElementById("scale").value='';
case '1':
document.getElementById("man").style.display="inline";
document.getElementById("scale").style.display="none";
document.getElementById("man").value='0';
document.getElementById("scale").value='';
case '2':
document.getElementById("man").style.display="none";
document.getElementById("scale").style.display="inline";
document.getElementById("man").value='';
document.getElementById("scale").value='0';
case '3':
document.getElementById("man").style.display="inline";
document.getElementById("scale").style.display="inline";
document.getElementById("man").value='0';
document.getElementById("scale").value='0';
}
}
</script>
<select id="all" name="all" onChange="all_changed();">
<option value='0'>All</option>
<option value='1'>Manufacture</option>
<option value='2'>Scale</option>
<option value='3'>Man' & Scale</option>
</select>
</td>
<td>
<select id="man" name="man" style="display:none">
<option value='0'>~Select~</option>
</select>
<select id="scale" name="scale" style="display:none">
<option value='0'>~Select~</option>
</select>
</td>
</tr>
<tr>
<td>
<input type="submit" value="select"> <input type="reset" value="clear" name="clear" onClick="clear_selected();">
</td>
</tr>
</form>

אך משום מה הקוד לא עובד... מה אני עושה לא בסדר? תודה!

פורסם

כמה דברים שעשית לא נכון

1. נתחיל מזה שהקוד שלך לא תקין (קוד ה HTML עצמו), תקן אותו בשביל שיעבוד טוב ב FF

2. רשמת onChange במקום onchange שוב פעם לא תקין ולא יעבוד ב FF תתקן בהתאם

3. בפקודה switch שרשמת לא רשמת בסוף כל אופציה את המילה break שזה מה שגרם לטעות שלך.

תקן את כל אלו ותראה שזה עובד.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/url]

<html xmlns="[url]http://www.w3.org/1999/xhtml">[/url]
<head>
<title></title>
<script language="JavaScript">
function clear_selected() {
document.getElementById("man").style.display="none";
document.getElementById("scale").style.display="none";
document.getElementById("man").value='';
document.getElementById("scale").value='';
}

function all_changed() {
switch(document.getElementById("all").value){
case '0':
document.getElementById("man").style.display = "none";
document.getElementById("scale").style.display = "none";
document.getElementById("man").value = '';
document.getElementById("scale").value = '';
break;
case '1':
document.getElementById("man").style.display = "inline";
document.getElementById("scale").style.display = "none";
document.getElementById("man").value = '0';
document.getElementById("scale").value = '';
break;
case '2':
document.getElementById("man").style.display = "none";
document.getElementById("scale").style.display = "inline";
document.getElementById("man").value = '';
document.getElementById("scale").value = '0';
break;
case '3':
document.getElementById("man").style.display = "inline";
document.getElementById("scale").style.display = "inline";
document.getElementById("man").value = '0';
document.getElementById("scale").value = '0';
break;
}
}
</script>
</head>
<body>
<form action="view.php" method="post" name="details">
<table cellpadding="0" cellspacing="0">
<tr>
<td>
<select id="all" name="all" onchange="all_changed();">
<option value='0'>All</option>
<option value='1'>Manufacture</option>
<option value='2'>Scale</option>
<option value='3'>Man' & Scale</option>
</select>
</td>
<td>
<select id="man" name="man" style="display:none">
<option value='0'>~Select~</option>
</select>
<select id="scale" name="scale" style="display:none">
<option value='0'>~Select~</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="select"> <input type="reset" value="clear" name="clear" onClick="clear_selected();">
</td>
</tr>
</table>
</form>
</body>
</html>

פורסם
  • מחבר

הבנתי, מעולה!

ארכיון

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

דיונים חדשים

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.