Autor | Zpráva | ||
---|---|---|---|
pista87 Profil |
#1 · Zasláno: 29. 9. 2007, 00:00:40 · Upravil/a: pista87
<script language="JavaScript">
function selectAllOptions(obj) { for (var i=0; i<obj.options.length; i++) { obj.options[i].selected = true; } } function addOption(theSel, theText, theValue) { var newOpt = new Option(theText, theValue); var selLength = theSel.length; theSel.options[selLength] = newOpt; } function deleteOption(theSel, theIndex) { var selLength = theSel.length; if(selLength>0) {theSel.options[theIndex] = null;} } function moveOptions(theSelFrom, theSelTo) { var selLength = theSelFrom.length; var selectedText = new Array(); var selectedValues = new Array(); var selectedCount = 0; var i; // Find the selected Options in reverse order // and delete them from the 'from' Select. for(i=selLength-1; i>=0; i--) { if(theSelFrom.options[i].selected) { selectedText[selectedCount] = theSelFrom.options[i].text; selectedValues[selectedCount] = theSelFrom.options[i].value; deleteOption(theSelFrom, i); selectedCount++; } } // Add the selected text/values in reverse order. // This will add the Options to the 'to' Select // in the same order as they were in the 'from' Select. for(i=selectedCount-1; i>=0; i--) { addOption(theSelTo, selectedText[i], selectedValues[i]); } } //--> </script> <form method=post action=""> <table border="0"> <tr> <td> <select name="sel1" size="10" multiple> <option value="1">lava1</option> <option value="2">lava2</option> </select> </td> <td align="center" valign="middle"> <input type="button" value="-->" onClick="moveOptions(this.form.sel1, this.form.sel2);" /><br /> <input type="button" value="<--" onClick="moveOptions(this.form.sel2, this.form.sel1);" /> </td> <td> <select name="sel2" size="10" multiple> <option value="1">prava1</option> <option value="2">prava2</option> </select> </td> </tr> </table> <input type=submit value=submit> </form> ako tu spracujem hodnoty zo sel2 v php? pozeral som na nete ze treba dat do toho selectu name='sel2[]' aby to bol array ale potom nefunguje to this.form.sel2 aj ked tam dam nakoniec to [] diky |
||
centi Profil |
#2 · Zasláno: 29. 9. 2007, 00:22:22
pista87
Nastav selectu i ID a v javascripte k nemu pristupuj práve cez ID.
Prípadne do tej funkcie predávaj len IDčka selectov a pristupuj k nim až vo funkcii:
|
||
pista87 Profil |
#3 · Zasláno: 29. 9. 2007, 00:47:21
okej to funguje... ale este mam jeden problem ako nastavit aby pri odoslani fomulara oznacilo cely select sel2?
|
||
Časová prodleva: 18 let
|
0