Reply to Re: onclick event

Your name:

Reply:


Posted by Jerry Stuckle on 05/20/06 06:44

juicy wrote:
> 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>
>
>

Your problem is the PHP code is executed on the server before the page is sent
to the client browser. Once the page has been delivered, the javascript runs.
But PHP has already done it's job and terminated.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация