ERLEDIGT
NEIN
NEIN
ANTWORTEN
7
7
ZUGRIFFE
452
452
EMPFEHLEN
-
Hey

ich habe eine schleife in der immer diese if Anweisung durchläuft:
aber irgendwas stimmt da nichtCode javascript:1
if(document.all_data.return_reason_+i.options[document.all_data.return_reason_+i.selectedIndex].value == "no_selection")
-
Moin,
falls du hiermitden Namen des select generieren willst...das geht so nicht.Code :1
return_reason_+i
Probiers so
Code :1
if(document.all_data.elements['return_reason_'+i].options[document.all_data.elements['return_reason_'+i].selectedIndex].value == "no_selection")
Falls no_selection wirklich im value-Attribut der <option> notiert ist, kannst du auch so etwas einfacher darauf zugreifen:
Code :1
if(document.all_data.elements['return_reason_'+i].value == "no_selection")
Geändert von Sven Mintel (21.01.09 um 17:42 Uhr)
-
Geht leider nicht, da steht:
document.all_data.elements['return_reason_'+i] is undefined.
Könnte ich das nicht irgendwie so machen:
Code :1
document.all_data.return_reason_i+.value
-
Wie heissen denn die Listen überhaupt?...und woher kommt i ?
Zeige mal dein Formular.
-
i kommt aus einer for Schleife die drum herum läuft
HTML-Code:<td bgcolor="effaff"><b>Return reason:</b></td> <td bgcolor="effaff"><select name="return_reason_<?=$count_id?>" style="width: 200px"> <option name="select_<?=$count_id?>" value="no_selection">- Select -</option> <option value="Doesnt like">Doesnt like</option> <option value="Damaged">Damaged</option> </select></td>
-
Zeige mal bitte das komplette (PHP)-Skript(inkl. dem JS-Teil)...aus der von dir geposteten Passage ist kein Grund für den Fehler ersichtlich.
-
Code :
1 2 3 4 5 6 7 8 9 10 11 12
function chkForm() { for(i=0; i < document.items.elements.length; i++) { if(document.items.elements[i].checked) { if(document.all_data.elements['return_reason_'+i].value == "no_selection") { alert("Felder!"); return false; } } } }
PHP-Code:while($test = mysql_fetch_object($re))
{
$count_id++;
HTML-Code:<form name="all_data" action="" method="post" onSubmit="return chkForm()"> ... <td bgcolor="effaff"><b>Return reason:</b></td> <td bgcolor="effaff"><select name="return_reason_<?=$count_id?>" style="width: 200px"> <option name="select_<?=$count_id?>" value="no_selection">- Select -</option> <option value="Doesnt like">Doesnt like</option> <option value="Damaged">Damaged</option> </select></td>
-
Hab die Antwort
Hatte einen Fehler in meiner for-Schleife.
Es muss so lauten:
Code :1
for(i=1; i <= document.items.elements.length; i++)
Ähnliche Themen
-
Select-Box: Value & Content auslesen
Von Mik3e im Forum Javascript & AjaxAntworten: 7Letzter Beitrag: 30.08.10, 14:32 -
Datenbank auslesen (select)
Von themonk im Forum C/C++Antworten: 3Letzter Beitrag: 16.09.09, 20:40 -
Formular Select Feldbeschreibung auslesen
Von Kahmoon im Forum PHPAntworten: 3Letzter Beitrag: 06.11.08, 14:25 -
Select Variable in PHP auslesen
Von Diablo82 im Forum PHPAntworten: 11Letzter Beitrag: 08.06.06, 13:46 -
select aus form auslesen
Von Hampfibius im Forum Javascript & AjaxAntworten: 3Letzter Beitrag: 13.06.05, 21:28





Zitieren
Login





