0

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=yes"; return false;'>
                  </p>
                  </td>

Edited by Dani: Formatting fixed

5
Contributors
6
Replies
8
Views
5 Years
Discussion Span
Last Post by karthik_ppts
0

Use [ CODE ] tags

if($reasons=='Internal'){
  header("Location: cart1.php");
}else{
  header("Location: cart.php");
}
exit;

Edited by diafol: n/a

0

Thanks ardav,
But it will be appreciable if you can tell me where to put the code i mean before on click or after onclick stmt

0

Hey dipusubhasis,

The php-code given by ardav is the same that I wanted to give it to you.
Please tell what exactly you want. the info. given by you is insufficient.

I mean the variable '$reason' from where will we get its information.

try this if this solves your problem. if not you need to tell the whole thing.

<?php
// The php Code to Select the page.
$page = "";
if($reasons=='Internal'){
  $page = "cart1.php";
}else{
  $page = "cart.php";
}

?>

<!-- Your HTML FORM -->
<td>
<p align="center">
<input name="Next" type="button" id="Next" value="Next" onmouseover="reasonempty();"onclick='javascript:window.location.href="<?php echo $page; ?>?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=yes"; return false;'>
</p>
</td>

Please Check if this works or not.

0

I think you need javascript. If I'm correct, try this

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
        <script type="text/javascript">
            function goto()
            {
                if(reasons=="Internal")
                {
                    window.location.href="cart1.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=yes"; 
                    return false;
                }
                else
                {
                    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=yes"; 
                    return false;
                }
            }
        </script>
    </head>
    
    <body>
    <!-- ......
    ......
    ...... -->
    <td>
    <p align="center">
    <input name="Next" type="button" id="Next" value="Next" onmouseover="reasonempty();" onclick='goto()'>
    </p>
    </td>
     <!-- ......
    ......
    ...... -->
    </body>
</html>

Edited by karthik_ppts: n/a

1

changing locations, not opening a window

"","top=0,left=400,width=1000,height=1000,menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes,status=yes";

is bull

Edited by almostbob: n/a

Votes + Comments
0

then the script may be like this

function goto()
{
if(reasons=="Internal")
{
window.open("cart1.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=yes'");
return false;
}
else
{
window.open("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=yes'");
return false;
}
}

Edited by karthik_ppts: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.