Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Help needed in IF else onclick

    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,"","to p=0,left=400,width=1000,height=1000,menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,status=yes" ; return false;'>
    </p>
    </td>





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

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,084
    Thanks
    23
    Thanked 593 Times in 592 Posts
    Because of all the baggage your new page needs, I'd do this in a function so you can follow what's going on:
    Code:
    <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
    Code:
    window.location.href="cart.php......
    is not right

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

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •