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="JavaS cript">
function getSurcharge(id )
{
var output;
if (document.getEl ementById("chks ur1").checked)
{output = output + "<? echo $strSurcharge1; ?>"; }
if (document.getEl ementById("chks ur2").checked)
{output = output + "<? echo $strSurcharge2; ?>"; }
if (document.getEl ementById("chks ur3").checked)
{output = output + "<? echo $strSurcharge3; ?>"; }
if (document.getEl ementById("chks ur4").checked){ output = output + "<? echo
$strSurcharge4; ?>"; }
document.getEle mentById(id).va lue= output;
}
<?php
$strSurcharge1 = "x1";
$strSurcharge2 = "x2";
$strSurcharge3 = "x3";
$strSurcharge4 = "x4";
?>
<input type=checkbox name="chksur1" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge1; ?>">
<input type=checkbox name="chksur2" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge2; ?>">
<input type=checkbox name="chksur3" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge3; ?>">
<input type=checkbox name="chksur4" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge4; ?>">
<textarea name= "f_duties" id = "duties" cols=100 rows=10>
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="JavaS cript">
function getSurcharge(id )
{
var output;
if (document.getEl ementById("chks ur1").checked)
{output = output + "<? echo $strSurcharge1; ?>"; }
if (document.getEl ementById("chks ur2").checked)
{output = output + "<? echo $strSurcharge2; ?>"; }
if (document.getEl ementById("chks ur3").checked)
{output = output + "<? echo $strSurcharge3; ?>"; }
if (document.getEl ementById("chks ur4").checked){ output = output + "<? echo
$strSurcharge4; ?>"; }
document.getEle mentById(id).va lue= output;
}
<?php
$strSurcharge1 = "x1";
$strSurcharge2 = "x2";
$strSurcharge3 = "x3";
$strSurcharge4 = "x4";
?>
<input type=checkbox name="chksur1" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge1; ?>">
<input type=checkbox name="chksur2" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge2; ?>">
<input type=checkbox name="chksur3" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge3; ?>">
<input type=checkbox name="chksur4" onclick="getSur charge('duties' )"
value="<? echo $strSurcharge4; ?>">
<textarea name= "f_duties" id = "duties" cols=100 rows=10>
Comment