Posted by juicy on 05/20/06 06:35
Hi,
I have 4 check box and a textarea. When user check each check box, it will
append text in the textarea. In onclick event, it calls getSurcharge
function and append value in variable output. My problem is I failed to
get value in php variable inside the function.
Please give some idea on the reason of the problem. Thanks.
<script language="JavaScript">
function getSurcharge(id)
{
var output;
if (document.getElementById("chksur1").checked)
{output = output + "<? echo $strSurcharge1; ?>"; }
if (document.getElementById("chksur2").checked)
{output = output + "<? echo $strSurcharge2; ?>"; }
if (document.getElementById("chksur3").checked)
{output = output + "<? echo $strSurcharge3; ?>"; }
if (document.getElementById("chksur4").checked){output = output + "<? echo
$strSurcharge4; ?>"; }
document.getElementById(id).value= output;
}
<?php
$strSurcharge1 = "x1";
$strSurcharge2 = "x2";
$strSurcharge3 = "x3";
$strSurcharge4 = "x4";
?>
<input type=checkbox name="chksur1" onclick="getSurcharge('duties')"
value="<? echo $strSurcharge1; ?>">
<input type=checkbox name="chksur2" onclick="getSurcharge('duties')"
value="<? echo $strSurcharge2; ?>">
<input type=checkbox name="chksur3" onclick="getSurcharge('duties')"
value="<? echo $strSurcharge3; ?>">
<input type=checkbox name="chksur4" onclick="getSurcharge('duties')"
value="<? echo $strSurcharge4; ?>">
<textarea name= "f_duties" id = "duties" cols=100 rows=10>
[Back to original message]
|