|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dynamic multi selection box
Hi,
I have a combo box which contains a no of values.On selecting any of these values and clicking a button,the selected value should get added to a multi select list(dynamically).And on selecting any value from the multi selection list and clicking another button ,the selected value should get removed from the multi selection list.Can anybody help. |
|
#2
|
|||||
|
|||||
|
RE: Dynamic multi selection box
quick example
php Code:
(put it in PHP tags for layout) |
|
#3
|
|||
|
|||
|
Thanks Crisp
Your code helped.Thanks Crisp.You are always there when we need help.
|
|
#4
|
|||
|
|||
|
RE: Dynamic multi selection box
Hi,
Nice coding! By the way, would you please to tell me how to get(or by "POST") those multi-selected variables out? I always get the last selected item out but not the whole list! :< I added this.... <form action="READ.php" method="post" name="myform"> and a "SUBMIT" button.... <input type="submit" name="Submit" value="Submit"> Thanks! Arnold |
|
#5
|
|||
|
|||
|
RE: Dynamic multi selection box
With multi selection list,you only get the selected values on submitting the form.SO before submitting,you need to select all the values in the select box.An examples is
Code:
function subform()
{
forr(i=0;i<document.form1.elements['to_players[]'].options.length;i++)
{
document.form1.elements['to_players[]'].options[i].selected=true;
}
document.form1.submit();
}
}
|
|
#6
|
||||||
|
||||||
|
RE: RE: Dynamic multi selection box
Quote:
eg : php Code:
|
|
#7
|
|||
|
|||
|
RE: Dynamic multi selection box
Hi,
Thanks! Actually I am doing a dynamic multi-selection box... I can display those selected items in a alert-box(i.e. in JavaScript)...so how can I pass these JS's variable to outside the HTML? I have tried to use Hidden-variable ... <input type="hidden" name=output_list" value=strSel>.... but failed :< Please give me a hand!!! Thanks in advance! Arnold =======HTML Listing (if you have time, please try it! :> )====== <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <script> <!-- items = ['CnEg','CiEgenEg','CoS','EEamp; Erig','Egt/ogt','MBue']; var checkboxAct = 0; function listAct() { for (var i = document.form1.bclass.options.length; i >= 0; i--){ document.form1.bclass.options[i] = null; } for (var i = document.form1.cclass.options.length; i >= 0; i--){ document.form1.cclass.options[i] = null; } if(checkboxAct==0){ document.form1.bclass.options[document.form1.bclass.options.length] = new Option('[no Program selected]','0'); document.form1.cclass.options[document.form1.cclass.options.length] = new Option('[no Program selected]','0'); } for (x=0; x<items.length; x++) { action = checkboxAct & poten(x); if (action != 0) { if(x==0){ document.form1.bclass.options[document.form1.bclass.options.length] = new Option('1-C Eg'); document.form1.bclass.options[document.form1.bclass.options.length] = new Option('2-C & en Eg'); document.form1.bclass.options[document.form1.bclass.options.length] = new Option('3-C & en Eg'); document.form1.bclass.options[document.form1.bclass.options.length] = new Option('4-C & en Eg'); document.form1.cclass.options[document.form1.cclass.options.length] = new Option('A-dfsdfgf'); document.form1.cclass.options[document.form1.cclass.options.length] = new Option('B-sdewfd'); document.form1.cclass.options[document.form1.cclass.options.length] = new Option('C-sdf djkf 23f'); document.form1.cclass.options[document.form1.cclass.options.length] = new Option('D-213dsf'); } } } } //--> </script> </head> <body> <form name="form1" method="post" action="adb.php"> <table width="100%" border="0"> <!--DWLayoutTable--> <tr> <td colspan="19" valign="top"><strong>Type:</strong></td> </tr> <tr valign="middle"> <td width="326" height="34"><input name="checkbox9" type="checkbox" onClick="actionVar(poten(0));listAct()"> CE</td> <td colspan="15"><!--DWLayoutEmptyCell--> </td> </tr> <tr valign="middle"> <td height="18"><!--DWLayoutEmptyCell--> </td> <td colspan="15"><!--DWLayoutEmptyCell--> </td> </tr> <tr> <td height="34" valign="middle"><!--DWLayoutEmptyCell--> </td> <td colspan="15" valign="middle"><!--DWLayoutEmptyCell--> </td> </tr> <tr> <td colspan="19" valign="top"><strong>Level:</strong></td> </tr> <tr> <td colspan="19" valign="top">Class1 <select name="bclass" size="3" multiple id="bclass"> <option>[no Program selected] </select> <em><font color="#FF0000" size="2">(can pick more than one selection)</font> </em></td></tr> <tr> <td colspan="19" valign="top">Class2</td> </tr> <tr> <td colspan="19" valign="top"><select name="cclass" size="3" multiple> <option>[no Program selected]</option> </select> <em> <font color="#FF0000" size="2">(can pick more than one selection)</font> </em></td> </tr> <hr> </table> <hr> <p align="center"> <input name="Submit" type="submit" id="Submit" value=" Submit "> <input type="reset" name="Submit2" value="Reset Form"> <input name="Submit3" type="button" id="Submit32" value="Cancel"> <INPUT name="BUTTON" TYPE=BUTTON ONCLICK="outputSelected(this.form.bclass.options),outputSel ected(this.form.cclass.options)" VALUE="Selected List Items"> </p> <script> function actionVar (numero) { checkboxAct ^= numero; } function poten ( exponente ) { calculo = 1; for (x=0;x<exponente;x++) { calculo = calculo*2; } return calculo; } function displayOpt() { for (x=0; x<items.length; x++) { document.write("<input type='checkbox' onClick='actionVar(" + poten(x) + ");'>" + items[x] + "<br>"); } } function getSelected(opt) { var selected = new Array(); var index = 0; for (var intLoop = 0; intLoop < opt.length; intLoop++) { if ((opt[intLoop].selected) || (opt[intLoop].checked)) { index = selected.length; selected[index] = new Object; selected[index].value = opt[intLoop].value; selected[index].index = intLoop; }}return selected; } function outputSelected(opt) { var sel = getSelected(opt); var strSel = ""; for (var item in sel) strSel += sel[item].value + ","; alert("Selected Items:n" + strSel); } </script> </form> </body> =========CUT TO HERE== |
|
#8
|
|||
|
|||
|
RE: Dynamic multi selection box
Hello,
Thanks for your hint! I get through it! |
|
#9
|
|||
|
|||
|
RE: Dynamic multi selection box
Hello,
Thanks for your hint! I get through it! |
|
#10
|
|||
|
|||
|
RE: Dynamic multi selection box
That's why I was silent. I thought you'll make it with my simple hint
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Client Side Things > Dynamic multi selection box |
| Thread Tools | Search this Thread |