View Full Version : document.submit problems

08-13-2004, 08:16 AM
I have a form:
rst("productversion") - is a loop from results from db query

<form name="amount<%=rst("productversionid")%>" method=get action="viewcart.asp" >

<select name="selRadio<%=rst("productversionid")%>" onChange="javascript: document.amount<%=rst("productversionid")%>.txtPrice<%=rst("productversionid")%>.value = this.options[this.selectedIndex].value;" class="dropdown">

<option value = "-" selected ></option>
<% bunch of sql junk in a loop for more option %>

<a href="javascript: addtocart(document.amount<%=rst("productversionid")%>);" target="_parent" class="left_headers_white">ADD TO CART</a>

function addtocart(e,productversionid)
var temp = eval('e.selRadio'+productversionid+'.value');
if (temp == "-")
alert('You must select a Quantity for this Product');


for the life of me I cannot get the bast'd to submit ... it simply does nothing... not even reload the current page... it does make a "click" noise
... wahoo ... any suggestions?

08-13-2004, 10:02 AM
function addtocart(e,productversionid)

That suppose you must have 2 parameters

function foo(param1,param2)

but it looks like you fired onevent with only one parameter, the form's reference:


Thus, your second parameter used in function, productversionid has no input...

08-13-2004, 06:45 PM
<a href="javascript: addtocart(document.amount<%=rst("productversionid")%>);" ...
should read:
<a href="javascript: addtocart(document.amount<%=rst("productversionid")%>,<%=rst("productversionid")%>);" ...

that's my bad I have that in my code I just copied it over wrong because I wanted to make it simpler

but even if it did pass that in productversionid would be null, not pass the if case, go into the else and should submit the form ...
no worky

08-13-2004, 08:51 PM
i've tried
didnt work
i even tried to just change the page
window.location.href = url that I want to go to
didnt work either ...

Willy Duitt
08-13-2004, 10:04 PM
It may be more helpful if you posted the code of the page after it has been parsed. But the problem may lie in the form name....


Try changing the double quotes used to enclose the form name with single quotes....


08-13-2004, 10:19 PM
<form name="amount3" method=get action="viewcart.asp" >

<select name="selRadio3" onChange="javascript: document.amount3.txtPrice3.value = this.options[this.selectedIndex].value;" class="dropdown">
<option value = "-" selected></option>
<option value="112.50"quantity = 50 >50</option>
<option value="337.50"quantity = 150 >150</option>
<option value="562.50"quantity = 250 >250</option>
<option value="787.50" quantity = 350 >350</option>
<option value="1,012.50" quantity = 450>450 </option>

<input name="txtPrice3" type="text" value="" size="8" onFocus="this.blur();" class="dropdown"></form>

<a href="javascript: addtocart(document.amount3,3);" target="_parent" class="left_headers_white">ADD TO CART</a>

tried with and without quotes everywhere I can think of... thanks for the try

Willy Duitt
08-13-2004, 10:44 PM
It worked for me using google as the form action.....

<script type="text/javascript">
function addtocart(e,productversionid){
var temp = eval('e.selRadio'+productversionid+'.value');
if(temp == "-"){
alert('You must select a Quantity for this Product');
} else{ e.submit() };

<form name="amount3" method="get" action="http://google.com" >
<select name="selRadio3" class="dropdown"
<option value = "-" selected></option>
<option value="112.50" quantity = 50> 50</option>
<option value="337.50" quantity = 150>150</option>
<option value="562.50" quantity = 250>250</option>
<option value="787.50" quantity = 350>350</option>
<option value="1,012.50" quantity = 450>450</option>

<input name="txtPrice3" type="text" value="" size="8"
onfocus="this.blur();" class="dropdown"></form>

<a href="javascript:addtocart(document.amount3,3)"
target="_parent" class="left_headers_white">ADD TO CART</a>


08-14-2004, 05:58 AM
I do not know my friend... still not working ...
I ended up doing some crazy vbscript and using
response.redirect and just sending in the variables using ?var=whateve&ect......

Matt RW
08-14-2004, 10:48 AM
but you didn't think of posting the output from the ASP so we could've seen what it was doing wrong...

08-16-2004, 05:58 AM
function addtocart(e,productversionid){
var sel = e.elements['selRadio'+productversionid];
if (sel.options[sel.selectedIndex].value == "-"){
alert('You must select a Quantity for this Product');
return false;
<a href="#" onclick="return addtocart(document.amount3, 3)" class="left_headers_white">ADD TO CART</a>