******************************** JAVASCRIPT VERSION <html> <head> <title>mytitle</title> <script language="JavaScript" type="text/javascript"> function multiply(x){ var myresult = 2 * x; document.write(myresult); } </script> </head> <body> <form name="myform" action="<?$PHP_SELF?>" method="POST"> <input type="button" name="mybutton" value="myvalue" onClick="multiply(5)"> </form> </body> </html> ********************************
******************************** PHP VERSION <html> <head> <title>mytitle</title> </head> <body> if($mybutton){ $myresult = 2 * $mybutton; print $myresult; }else{ print "Click the button to see what 2 mulitplied by 5 is!"; } <form name="myform" action="<?$PHP_SELF?>" method="POST"> <input type="button" name="mybutton" value="5" onClick="mysubmit()"> </form> </body> </html> ******************************** You can do it either way, don't take my code at face "value" (sorry, couldn't resist) I haven't tested it, but it should be enough to get you going. I would suggest that you use the PHP version, that way you don't have to worry about cross browser JavaScript compatibility. >> > 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 > > > -- 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]