jc_gmk
04-02-2008, 02:51 PM
I've got a form that is submitted by a link rather than a submit button.
The following code works great with internet explorer but not firefox, any ideas?
<a href="#" onclick="return submititems(this.form);"><img src="content/images/submit.jpg" /></a>
<script type="text/javascript" language="javascript">
function submititems(thisform)
{
for (var q=0, e=this.orderqty.elements, i = e.length-1; i > -1; --i)
{
if (e[i].name && e[i].name=='qty[]' && !isNaN(+e[i].value))
{
q+= +e[i].value;
}
}
if (q==0)
{
alert("you have not selected any products");
}
else
{
if (q==1)
{
if (confirm("add " +q+ " product to the shopping cart?"))
{
document.orderqty.submit();
}
else
{
return false;
}
}
else
{
if (confirm("add " +q+ " products to the shopping cart?"))
{
document.orderqty.submit();
}
else
{
return false;
}
}
}
}
</script>
The following code works great with internet explorer but not firefox, any ideas?
<a href="#" onclick="return submititems(this.form);"><img src="content/images/submit.jpg" /></a>
<script type="text/javascript" language="javascript">
function submititems(thisform)
{
for (var q=0, e=this.orderqty.elements, i = e.length-1; i > -1; --i)
{
if (e[i].name && e[i].name=='qty[]' && !isNaN(+e[i].value))
{
q+= +e[i].value;
}
}
if (q==0)
{
alert("you have not selected any products");
}
else
{
if (q==1)
{
if (confirm("add " +q+ " product to the shopping cart?"))
{
document.orderqty.submit();
}
else
{
return false;
}
}
else
{
if (confirm("add " +q+ " products to the shopping cart?"))
{
document.orderqty.submit();
}
else
{
return false;
}
}
}
}
</script>