how to submit all items from a multiple select control to an

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > Classic ASP

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Dec 31st, 2004, 07:56
New Member
Join Date: Dec 2004
Location: Philippines
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to andrew_perez5
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>

  #2 (permalink)  
Old Dec 31st, 2004, 08:36
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
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.
  #3 (permalink)  
Old Jan 1st, 2005, 14:06
New Member
Join Date: Dec 2004
Location: Philippines
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to andrew_perez5
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!
  #4 (permalink)  
Old Jan 4th, 2005, 20:16
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
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.
  #5 (permalink)  
Old Jan 5th, 2005, 01:59
New Member
Join Date: Dec 2004
Location: Philippines
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to andrew_perez5
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?
  #6 (permalink)  
Old Jan 5th, 2005, 07:40
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
<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)
  #7 (permalink)  
Old Jan 5th, 2005, 13:28
New Member
Join Date: Dec 2004
Location: Philippines
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to andrew_perez5
Thank you so much! I really appreciate ur help... I will try these codes and I hope this one works...
Closed Thread

Tags
submit, items, multiple, select, control

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 05:13.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43