PHP is entirely server-based.  So when you load this page into your 
browser, all of the PHP is being parsed BEFORE it ever loads into the 
browser.  So the function will be executed even before the page loads.

Do it in JavaScript if you want it to be done in the browser.  What you 
have written down will show up in the source code of your browser as:

<INPUT TYPE="BUTTON" NAME="HH" value="Mul" onClick="1">

(or something like that).

PHP runs entirely on the 
server.  Server!  Server!  Server!  Server!  Honest, I promise that it 
doesn't get interpreted by the browser.  If you have any doubts, try 
writing a PHP script, reading it in your browser, and then viewing the 
source code to see what gets rendered.

For browser-side scripting, I suggest you pick up a book on JavaScript 
programming.  Nothing you do in PHP will ever be interpreted by a browser.


At 01:59 PM 1/11/2002, Nick Wilson wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>
>* On 11-01-02 at 22:48
>* Morten Nielsen said....
>
> > Hi,
> >
> > I am rather new to PHP so I hope somebody can help me.
> >
> > I have a normal button (HTML code). Then I have made a function
> >
> > function multiply($X)
> > {
> >     return 2*$X;
> > }
> >
> > The button has an OnClick, which calls my function.
> > <INPUT TYPE="BUTTON" name="HH" value="Mul" onClick="<? 
> $XX=multiply(5);?>" >
> >
> > I then writes $X to the screen.
> >
> > <?php echo $X ?>
> >
> > The problem is I dont even have to press the button. When the page loads it
> > already has calculated 2*$X. Why is that. I would like to only call my
> > function when I press my button.
>
>What value is it returning 5, or 10?
>
>Nick Wilson
>
>Tel:    +45 3325 0688
>Fax:    +45 3325 0677
>Web:    www.explodingnet.com
>
>
>
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.0.6 (GNU/Linux)
>Comment: For info see http://www.gnupg.org
>
>iD8DBQE8P2ArHpvrrTa6L5oRAhPjAJ9Mv4k54bNNtu8DLGBegiD7SaQA1QCggJNl
>PolIOd8coSStooSyW/mmtk0=
>=MNoe
>-----END PGP SIGNATURE-----
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>To contact the list administrators, e-mail: [EMAIL PROTECTED]


Sliante,
Richard S. Crawford

http://www.mossroot.com
AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
MSN: [EMAIL PROTECTED]

"It is only with the heart that we see rightly; what is essential is 
invisible to the eye."  --Antoine de Saint Exupéry

"Push the button, Max!"


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to