...

View Full Version : Help needed in IF else onclick



dipusubhasis
12-21-2011, 12:53 PM
Hi guys i am new to this forum facing some issues with my php code.
The code below says on click go to cart.php
I want to add a condition to the same--

if(reasons==Internal)
{
go to="cart1.php"
}
else
{
go to="cart.php"
}

Kindly help me with the same....
<td>
<p align="center">
<input name="Next" type="button" id="Next" value="Next" onmouseover="reasonempty();"onclick='javascript:window.location.href="cart.php?form=tmrfForm&field="+document.getElementById("reasons").value+"&field5="+document.getElementById("weekend").value,"","top=0,left=400,width=1000,height=1000,menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,status=ye s"; return false;'>
</p>
</td>





Will appreciate if pls put the code .......

sunfighter
12-21-2011, 06:56 PM
Because of all the baggage your new page needs, I'd do this in a function so you can follow what's going on:

<input name="Next" type="button" id="Next" value="Next" onmouseover="reasonempty();"onclick="changePage();"

In changePage() use the if/else frame work as you have stated and go to the page you want to go to.

BUT
window.location.href="cart.php...... is not right


window.location="cart.php...... is how it's done.


<script type="text/javascript">
function changePage() {
if(reasons==Internal)
{
window.location="cart.php......
}
else
{
window.location="cart2.php......
}
}
</script>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum