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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While Not RS.EOF, popup value 1

Status
Not open for further replies.

Kendel

Programmer
Apr 24, 2002
1,512
0
0
US
Hello,

I'm trying to write a VBscript function to popup some value from clients side but I it doesn't work.

Here is my code:

<%While Not RS.EOF %>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;nextpage&quot;>
<table>
<tr><td>Price:<input type=&quot;text&quot; name=&quot;price&quot; value=&quot;<%=RS(&quot;price&quot;)%>&quot;>
</td></tr>
<tr><td>Number of items:
<select name=&quot;NumItems&quot; size=1>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
</select>
</td></tr>
<tr><td>
<input type=&quot;button&quot; name=&quot;btn1&quot; value=&quot;Add to cart&quot; onClick=&quot;Call Add2Cart&quot;>
</td></tr>
<tr><td><input type=&quot;submit&quot; value=&quot;submit&quot;></td></tr>
</table>
</form>

<%
RS.MoveNext
WEND
%>

<script language=&quot;vbscript&quot;>
Function Add2Cart
document.form2.F2price.value = document.form1.price.value
document.form2.F2Items.value = document.form1.NumItems.value
End Function
</scrip>

<form name=&quot;form2&quot;>
<input type=&quot;text&quot; name=&quot;F2price&quot;>
<input type=&quot;text&quot; name=&quot;F2Items&quot;>
</form>

While not end of file when the &quot;Add to cart&quot; button is clicked, the values of textbox in form2 are set to values of those in form 1.

Can someone please help me out? I got the error &quot;obj doesn't support this property or method&quot; in line
document.form2.F2price.value = document.form1.price.value

Thanks in advance.
 
By putting the following line INSIDE your loop, you write multiple forms named &quot;form1&quot;

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;nextpage&quot;>

Pull it out of the loop...

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;nextpage&quot;>
<%While Not RS.EOF %>
<table>


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
Thanks for your input. I do need more than 1 form though. Do you notice each form has a submit button? I do want to submit the form seperately.

I guess I have to name the forms differently. How?
 
OK, here's the deal.

If you look at the HTML that is produced from your code, you will see that if you have more than 1 row in your recordset, you will have as an example:

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;nextpage&quot;>
<table>
<tr><td>Price:<input type=&quot;text&quot; name=&quot;price&quot; value=&quot;123.00&quot;>
</td></tr>
<tr><td>Number of items:
<select name=&quot;NumItems&quot; size=1>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
</select>
</td></tr>
<tr><td>
<input type=&quot;button&quot; name=&quot;btn1&quot; value=&quot;Add to cart&quot; onClick=&quot;Call Add2Cart&quot;>
</td></tr>
<tr><td><input type=&quot;submit&quot; value=&quot;submit&quot;></td></tr>
</table>
</form>

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;nextpage&quot;>
<table>
<tr><td>Price:<input type=&quot;text&quot; name=&quot;price&quot; value=&quot;234.00&quot;>
</td></tr>
<tr><td>Number of items:
<select name=&quot;NumItems&quot; size=1>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
</select>
</td></tr>
<tr><td>
<input type=&quot;button&quot; name=&quot;btn1&quot; value=&quot;Add to cart&quot; onClick=&quot;Call Add2Cart&quot;>
</td></tr>
<tr><td><input type=&quot;submit&quot; value=&quot;submit&quot;></td></tr>
</table>
</form>

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;nextpage&quot;>
<table>
<tr><td>Price:<input type=&quot;text&quot; name=&quot;price&quot; value=&quot;567.00&quot;>
</td></tr>
<tr><td>Number of items:
<select name=&quot;NumItems&quot; size=1>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
</select>
</td></tr>
<tr><td>
<input type=&quot;button&quot; name=&quot;btn1&quot; value=&quot;Add to cart&quot; onClick=&quot;Call Add2Cart&quot;>
</td></tr>
<tr><td><input type=&quot;submit&quot; value=&quot;submit&quot;></td></tr>
</table>
</form>

What I'm trying to say is that you will have many form1's. Try the following:

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;nextpage&quot;>
<table>
<tr><td>Price:<input type=&quot;text&quot; name=&quot;price&quot; value=&quot;<%=RS(&quot;price&quot;)%>&quot;>
</td></tr>
<tr><td>Number of items:
<select name=&quot;NumItems&quot; size=1>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
<option value=&quot;1&quot;>1</option>
</select>
</td></tr>
<tr><td>
<input type=&quot;button&quot; name=&quot;btn1&quot; value=&quot;Add to cart&quot; onClick=&quot;Add2Cart(price.value, NumItems.value);&quot;>
</td></tr>
<tr><td><input type=&quot;submit&quot; value=&quot;submit&quot;></td></tr>
</table>
</form>

<%
RS.MoveNext
WEND
%>

<script language=&quot;JavaScript&quot;>
Function Add2Cart(astr_price, astr_numitems)
{
document.form2.F2price.value = astr_price;
document.form2.F2Items.value = astr_numitems;
}
</script>

<form name=&quot;form2&quot;>
<input type=&quot;text&quot; name=&quot;F2price&quot;>
<input type=&quot;text&quot; name=&quot;F2Items&quot;>
</form>


 
Thanks ppepin, I think you have pointed me to the right direction. But noe, I get this runtime error:

&quot;document.form2.F2price&quot; is null or not an object.
 
I am so desperate for this. Can someone please help me out?

Thanks a bunch.

-kendel
 
I'm so sorry ppepin. My bad. Your code works like a champ. I missed some html tag in my form and it screwed up.

Here is a star for you.
 
Hi all,

Everything works just fine so far. Now in Form2, the number of table row depends on number of record count. What do I need to modify the Add2Cart function to assign these values?


<script language=&quot;JavaScript&quot;>
Function Add2Cart(astr_price, astr_numitems)
{
document.form2.F2price.value = astr_price;
document.form2.F2Items.value = astr_numitems;
}
</script>

<form name=&quot;form2&quot;>
<table>
<% For i=1 to RS.RecordCount %>
<tr><td>
<input type=&quot;text&quot; name=&quot;F2price&quot;>
<input type=&quot;text&quot; name=&quot;F2Items&quot;>
</td></tr>
<% Next %>
</table>
</form>
 
Can someone please help me with the above question?

Another question: I don't want user to change the value in this box:
<input type=&quot;text&quot; name=&quot;F2price&quot;>

If I disbale it, I won't be able to pass this value to the next form. Is there a way to label it?

Many thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top