| Autor | Zpráva | ||
|---|---|---|---|
| pista87 Profil |
#1 · Zasláno: 30. 9. 2007, 21:58:28
ako spravim aby pri stlaceni tlacitka submit vo formulari, oznacilo cely <select> a odoslalo formular
|
||
| Joker Profil |
#2 · Zasláno: 30. 9. 2007, 22:17:23
Předpokládám, že "oznacit <select>" znamená vybrat všechny možnosti v multiselect prvku?
Zhruba takhle: function neco(){ var el = document.getElementById ? document.getElementById("tenSelect") : false; if(el) opts = el.options; if(!opts) return(); for(var i=0; i< opts.length; i++){ opt[i].selected = true; } document.forms.nejakyFormular.submit() } |
||
| pista87 Profil |
#3 · Zasláno: 30. 9. 2007, 23:21:32
nejako to nefunguje mozno preto, lebo toho tam mam viac...
mam 2 multi-selecty , vlavo je multiselect zoznam poloziek a presuvam to do praveho multiselectu, potom ked je vsetko vybrane potrebujem aby pri stlaceni tlacitka submit oznacilo cely pravy multiselect a odoslalo formular Tu je moj kod. <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; 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++; } } for(i=selectedCount-1; i>=0; i--) { addOption(theSelTo, selectedText[i], selectedValues[i]); } } //--> </script> <form method=post action=""> <table border="0" align="center"> <tr> <td> <select name="zoznam" size="10" multiple="multiple" style="width:240px;"> <option value='1'>option1</option> <option value='2'>option1</option> <option value='3'>option1</option> </select> </td> <td align="center" valign="middle"> <input type="button" value="-->" onClick="moveOptions(this.form.zoznam, document.getElementById('mySelect'));" /><br /> <input type="button" value="<--" onClick="moveOptions(document.getElementById('mySelect'), this.form.zoznam);" /> </td> <td> <select name="select2" id="mySelect" size="10" multiple="multiple" style="width:240px;"> </select> </td> </tr> </table> <table align="center"> <tr> <td><input type="submit" value="Uložiť"></td> </tr> </table> </form> |
||
|
Časová prodleva: 18 let
|
|||
0