This is a discussion on "how to submit all items from a multiple select control to an" within the Classic ASP section. This forum, and the thread "how to submit all items from a multiple select control to an are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
how to submit all items from a multiple select control to an
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
how to submit all items from a multiple select control to an
Hi, this is Bon from the Phil. I really need some help from some experts out there.
I have a form with two multiple select control (I named the first as cbo_source and the second as cbo_target). Once the form is loaded, the cbo_source loads all items from an MS Access database. Once i click the button >>, all the selected fields from the cbo_source should be transferred on the cbo_target control. Well, I'm done with that using javascript, my problem is how am i going to get all the items from the cbo_target control once i submitted the form? I can only get items that are selected on the cbo_target, but what i need is to get all items from the cbo_target regardless if it's selected or not. Here is my code: <%@ LANGUAGE="VBSCRIPT"%> <%Option Explicit dim cnn, rst,rs_client dim str_names Set cnn = Server.CreateObject("ADODB.Connection") cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Schedule_Dbase\QI_schedule.mdb;Mode=Read Write;Persist Security Info=False" cnn.Open Set rst = Server.CreateObject("ADODB.Recordset") rst.ActiveConnection = cnn rst.CursorType = 1 rst.LockType = 3 Set rs_client = Server.CreateObject("ADODB.Recordset") rs_client.ActiveConnection = cnn rs_client.CursorType = 1 rs_client.LockType = 3 %> <html> <head> <script LANGUAGE="vbscript"> <script type="text/javascript"> function mover(move) <%Session("test") = "Bon"%> { var x = 0 if(move == 'remove') { for(x = 0;x<(document.frm_post.cboname_target.length);x++) { if(document.frm_post.cboname_target.options[x].selected) { with(document.frm_post.cboname_source) { options[options.length] = new Option(document.frm_post.cboname_target.options[x].text,document.frm_post.cboname_target.options[x].value); } document.frm_post.cboname_target.options[x] = null; x = -1; } } } if(move == 'add') { for(x = 0;x<(document.frm_post.cboname_source.length);x++) { if(document.frm_post.cboname_source.options[x].selected) { with(document.frm_post.cboname_target) { options[options.length] = new Option(document.frm_post.cboname_source.options[x].text,document.frm_post.cboname_source.options[x].value); } document.frm_post.cboname_source.options[x] = null; x = -1; } } } return true; } </script> </head> <form name="frm_post" method="POST" action="add_new_sched.asp"> <select size="8" name="cboname_source" multiple> <% rst.Open "SELECT * from tbl_Emp_Profile" Do while rst.EOF = False %> <option><%=rst("Name")%></option> <%rst.movenext Loop %> </select></font> <input type="button" value=">>" name="cmdchoose" onclick="mover('add')"> <input type="button" value=" X " name="cmdremove" onclick="mover('remove')"> <select size="8" name="cboname_target" multiple> <input type="submit" value="Submit" name="B1"> </form> </html> |
|
|
|
|||
|
Instead of using a submit type button use a regular button or a link/image button to call a javascript function to submit the form. In that function, prior to calling the .submit() method of the form, use javascript to select all the options in your select control. Then they'll all get passed.
I assume with what you have so far you're somewhat familiar with javascript so I only answered in general terms. If you need more details let me know and I can help out more. |
|
|||
|
I had also some values of controls to pass on the asp page like checkbox, radio button, textbox and some combo boxes. Im not actually familiar in selecting all values for my select control using javascript. Can u please give me a sample code in details because I just also found the javascript code above from another forum and im really not that familiar yet.This will mean that I will also need to pass the values of my other controls with that javascript function? Can u also help me with that?Is there a way to do that using a vbscript function instead? But anyways,in whatever ways as long as it will work.
I'll appreciate very much your help! |
|
|||
|
The other controls will be passed automatically so long as they're within the form tags, the javascript only need to select all the options in the one box. If you could open a post in the javascript forum I'll help you with the code for that.
|
|
|||
|
Just a question. Is it possible to hide a textbox using javascript or vbscript on body onload?If its possible with vbscript, can u provide me a code for that?Also, if i have a vbscript function on a certain form and I assigned some values on an array variable on that function, is there a way for me to retrieve the values of that array on another asp page once i submitted the form?
|
|
|||
|
<blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />Is it possible to hide a textbox <hr height="1" noshade="noshade" id="quote" /></blockquote id="quote">
you can do it with CSS with style="visibility:hidden;" it'll do it before the onload. <blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />is there a way for me to retrieve the values of that array <hr height="1" noshade="noshade" id="quote" /></blockquote id="quote"> you'd have to pass the array by moving the values into something like a hidden form field. <blockquote id="quote" class="ffs">quote:<hr height="1" noshade="noshade" id="quote" />if i have a vbscript function on a certain form <hr height="1" noshade="noshade" id="quote" /></blockquote id="quote"> vbscript, by the way, isn't the best choice for a client-side language as it won't work on many non-IE browsers (unless you know only IE people will use it) |
![]() |
| Tags |
| submit, items, multiple, select, control |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Select records based on multiple conditions - need help | Love2Java | Databases | 9 | Oct 29th, 2007 14:37 |
| summerizing multiple items at once. | Javilen | Databases | 1 | Sep 20th, 2007 20:45 |
| Alignment issue in table with multiple select | peacher | Web Page Design | 2 | Aug 23rd, 2007 07:35 |
| Validation problem with multiple submit buttons | celia05es | JavaScript Forum | 2 | Sep 29th, 2005 08:19 |
| Menu List. Select Multiple without Ctrl+Click? | Andy K | JavaScript Forum | 7 | May 10th, 2005 09:01 |