sazzie Posted January 25, 2007 Share Posted January 25, 2007 I have a simple form in a php script which uses a button as shown below:[code] <input type="button" value="Add Course Information" name="add" onClick="'private/test2.php'"> [/code]The problem is the button does not go to test2.php.Can anyone see whats wrong with this line? Link to comment https://forums.phpfreaks.com/topic/35676-onclick-to-php/ Share on other sites More sharing options...
kenrbnsn Posted January 25, 2007 Share Posted January 25, 2007 PHP is executed on the server, Javascript on the client. By the time Javascript gets control of the code, PHP is long gone. You need to use AJAX techniques to do this.Ken Link to comment https://forums.phpfreaks.com/topic/35676-onclick-to-php/#findComment-169006 Share on other sites More sharing options...
dgiberson Posted January 25, 2007 Share Posted January 25, 2007 i take it your trying to call a function from test2.php? Link to comment https://forums.phpfreaks.com/topic/35676-onclick-to-php/#findComment-169015 Share on other sites More sharing options...
TEENFRONT Posted January 25, 2007 Share Posted January 25, 2007 If yourt just trying to submit the form info to test2.php, use a simple submit button. Link to comment https://forums.phpfreaks.com/topic/35676-onclick-to-php/#findComment-169027 Share on other sites More sharing options...
sazzie Posted January 26, 2007 Author Share Posted January 26, 2007 [quote author=dgiberson link=topic=123998.msg513241#msg513241 date=1169740943]i take it your trying to call a function from test2.php?[/quote]Yes, I am trying to call a function in test2.php. At present I have got it to go in and execute some code.I am now trying to pass some form element values without much success. The code is as follows : [code] <input type="button" value="Add Course Information" onClick="parent.location='private/test2.php?start=document.form1.<?php print "start";?>'">[/code]The "parent.location= " aspect allows test2 to be called sucessfully.document.form1.<?php print "start";?> is supposed to return an integer value but I get string.Form1 is the name of my form and start is an input element name.Believe me, I know it is easier to simply use the traditional get/post methods but I am required to do it this way.It will take too long to explain.Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/35676-onclick-to-php/#findComment-169565 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.