PDA

View Full Version : Javascript document.href



mbmunnithan
09-03-2008, 05:10 AM
am using the script below to activate multiple links that returns to the same page. and the form action is to another page. But am getting only the final link activated. But if am using alert box after socument.location.href all links working fine. How can i get all my link to get actuvated in the loop and to redirect to the action page.please help me.

<form name="ok" action="<?php echo $this->helper('catalog/product_compare')->getListUrl() ?>" >
<br>
<div style="float:right">
<button class="form-button-alt" onclick="checkValues()" >
<span>
<?php echo $this->__('Compare Items') ?>
</span>
</button>

<script>
<!--
function checkValues()
{
var x=document.getElementsByName("product[]");
for(i=0;i<=x.length;i++)
{
if(x[i].checked == true)
{

document.location.href=x[i].value;
}
}
document.getElementById("ok").submit()
}

//-->
</script>