Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Posting values from one asp to another asp.

Status
Not open for further replies.

ejg

Programmer
Aug 17, 2001
19
US
I have a question in regards to passing values from one asp page to another. My problem is that I have set up a page that allows users to input multiple values into a muliple value list box. (for instance user types in 1234 presses add and value is placed in list2............) My problem is that I need to be able to pass the values in list2 to the second asp page... When I try to access the values in the second list, I don't receive any information, I can retrieve the information from list1....not list2.See the attached asp pages.

any help would be greatly appreciated!

......................................

PAGE 1
--------
<HEAD>

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>

function move(fbox,tbox) {
var i = 0;
if(fbox.value != &quot;&quot;) {
var no = new Option();
no.value = fbox.value;
no.text = fbox.value;
tbox.options[tbox.options.length] = no;
fbox.value = &quot;&quot;;
}
}
function remove(box) {
for(var i=0; i<box.options.length; i++) {
if(box.options.selected && box.options != &quot;&quot;) {
box.options.value = &quot;&quot;;
box.options.text = &quot;&quot;;
}
}
BumpUp(box);
}
function BumpUp(abox) {
for(var i = 0; i < abox.options.length; i++) {
if(abox.options.value == &quot;&quot;) {
for(var j = i; j < abox.options.length - 1; j++) {
abox.options[j].value = abox.options[j + 1].value;
abox.options[j].text = abox.options[j + 1].text;
}
var ln = i;
break;
}
}
if(ln < abox.options.length) {
abox.options.length -= 1;
BumpUp(abox);
}
}
function Moveup(dbox) {
for(var i = 0; i < dbox.options.length; i++) {
if (dbox.options.selected && dbox.options != &quot;&quot; && dbox.options != dbox.options[0]) {
var tmpval = dbox.options.value;
var tmpval2 = dbox.options.text;
dbox.options.value = dbox.options[i - 1].value;
dbox.options.text = dbox.options[i - 1].text
dbox.options[i-1].value = tmpval;
dbox.options[i-1].text = tmpval2;
}
}
}
function Movedown(ebox) {
for(var i = 0; i < ebox.options.length; i++) {
if (ebox.options.selected && ebox.options != &quot;&quot; && ebox.options[i+1] != ebox.options[ebox.options.length]) {
var tmpval = ebox.options.value;
var tmpval2 = ebox.options.text;
ebox.options.value = ebox.options[i+1].value;
ebox.options.text = ebox.options[i+1].text
ebox.options[i+1].value = tmpval;
ebox.options[i+1].text = tmpval2;
}
}
}
// End -->
</script>

</HEAD>



<BODY>

<form action=&quot;devx1.asp&quot; method=&quot;POST&quot; name=&quot;parmform&quot;>
<table>
<tr>
<td>
<input type=&quot;text&quot; name=&quot;list1&quot; value=&quot;&quot;>
</td>
<td>
<input type=&quot;button&quot; value=&quot;Add&quot; onclick=&quot;move(this.form.list1,this.form.P1)&quot; name=&quot;B1&quot;><br>
<input type=&quot;button&quot; value=&quot;Delete&quot; onclick=&quot;remove(this.form.P1)&quot; name=&quot;B2&quot;><br><br>
<input type=&quot;button&quot; value=&quot;Up&quot; onclick=&quot;Moveup(this.form.P1)&quot; name=&quot;B3&quot;><br>
<input type=&quot;button&quot; value=&quot;Down&quot; onclick=&quot;Movedown(this.form.P1)&quot; name=&quot;B4&quot;>
</td>
<td>
<select multiple size=7 name=&quot;P1&quot;>
The Value Specified is

<%Request.Form (&quot;P1&quot;)%>
</select>
</td>
</tr>
<td colspan=&quot;2&quot;>
<p align=&quot;center&quot;>
<input type=&quot;submit&quot; name=&quot;B5&quot; value=&quot;View Report&quot;>
</p>
</td>
</tr>
</table>
</form>

<p><center>
----------------------------------------------
Receiving Page

<HTML>
<HEAD>
<META NAME=&quot;GENERATOR&quot; Content=&quot;Microsoft Visual Studio 6.0&quot;>
<TITLE></TITLE>
</HEAD>
<BODY>
<%=Request.Form%>
<BR>
<BR>
THE INFORMATION IS
<%=Request.Form(&quot;P1&quot;)%>
<P>&nbsp;</P>

</BODY>
</HTML>



 
where is your list2?

I looked through your code, and I didn't see any reference to list2... I see the reference to list1, but not list2...

 
vasah20,

The second list is actually being represented as P1
see.....
<select multiple size=7 name=&quot;P1&quot;

Any help is appreciated!

regards,
ejg
 
The problem looks like none of the values in your list2 (&quot;P1&quot;) are selected. When you submit a form it will check list boxes and pass the information that has been selected. In your case you are passing new values (options) to the list box but they are not selected and therefore not going to be passed when you submit the form.
The first option would be to select the new value you have added to the list box when you add it:

function move(fbox,tbox) {
var i = 0;
if(fbox.value != &quot;&quot;) {
var no = new Option();
no.value = fbox.value;
no.text = fbox.value;
no.selected = true;
tbox.options[tbox.options.length] = no;
fbox.value = &quot;&quot;;
}
}

This however would cause problems the way you have the ability for the user to move things up and down. The next way would be make your submit a type 'button' and then run a function that would loop through all the options in the list box and select them before submitting.

function submitList(element)
{
for(var i=0; i<element.options.length; i++)
{
element.selected = true;
}
document.parmform.submit()
}


Then modify your submit button to:

<input type=&quot;button&quot; name=&quot;B5&quot; value=&quot;View Report&quot; onclick=&quot;submitList(this.form.P1)&quot;>

This should take care of it and select all the options in the list box before submitting the form and then the values will be passed to you request object.
 
Hi All,

Thanks for all of the help with this one. I placed the no.selected = true into the move funtion and all works perfectly. I can live without the additional options that no longer work. (move values up and down)

again thanks for all of the help!

ejg
 
On another note.......I am wondering if it is possible (and if so how) to import the values from a standard text file (on client) into an array (list box)

So in the above mentioned situation.....instead of the user adding each item, they would have the capability to import a text file...and have the items in the text file show up in the passing list?

any help again is appreciated.

ejg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top