Needy11
asked on
jscript if statement
I need to redirect to a differnt thank you page at the end of a booking process based on a variable called yes_no. The variable is displayed fine in the HTML see fist line with %yes_no% and displays as 'yes' on the final page but when I try to convert this to a form that can be used in javascript I cannot get the variable to be assigned this value correctly. Anyone know the syntax I should be using. See below for what I have tried...
Tx Ciaran
Tx Ciaran
body
{
font-family:Arial, sans-serif;
line-height:1.5em;
background-color:transparent
}
</style>
<meta name='GENERATOR' content='MSHTML 9.00.8112.16448'/>
</head>
<body >
<div >%yes_no%</div>
<div > </div>
<div >
<script type="text/javascript">
var paymethod;
var test2 = "Test2";
window.alert(test2);
paymethod = %yes_no%;
window.alert(paymethod);
if (paymethod == "yes")
{
window.alert("Paypal");
document.write("Paypal");
}
else
{
window.alert("Invoice");
document.write("Invoice");
}
</script>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No worries. I tried assigning paymethod with both document.getElementById('Y esNo').val (); and document.getElementById('Y esNo').inn erhtml(); but the value didn't take even though it displays as innerhtml.
Any ideas why? - http://elearning.ahead.ie/forms/signup/signup.php
Any ideas why? - http://elearning.ahead.ie/forms/signup/signup.php
<script type="text/javascript">
var paymethod = document.getElementById('YesNo').innerhtml();
var test2 = "Test2";
window.alert(test2);
window.alert(paymethod);
if (paymethod == "yes")
{
window.alert("Paypal");
document.write("Paypal");
}
else
{
window.alert("Invoice");
document.write("Invoice");
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for that () removed. Any idea why paymethod var is undefined though. I have assigned it's value and defined it.
Tx
Ciaran
Tx
Ciaran
ASKER
Its ok I used textContent property instead and it works!! Thanks you.
Ciaran
Ciaran
ASKER
Here is the webpage if thats any help....
http://elearning.ahead.ie/forms/signup/signup.php