Calling PHP function onClick

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
victorsk
Forum Commoner
Posts: 43
Joined: Thu Apr 19, 2007 6:55 pm

Calling PHP function onClick

Post by victorsk »

Hello folks,

I am a total PHP newbie and need to figure out a way how to invoke a PHP method when user clicks a button. Here is my code for this:

Code: Select all

echo '<img src="http://10.242.225.201:8080/spacer.gif" height="0" width="400"><input type="submit" name="TourSubmit" value="Add to cart" onClick="CheckTourAvailability('.$val->outputIndex.')">'
I absolutely must use objects within the same file because these objects are used to invoke CheckTourAvailability SOAP API using the parameter $val->outputindex. To make things more complicated, I must also pass JavaScript form values obtained from drop down listboxes like this: mainform.listbox1.value and $val->outputIndex.

Right now I am using embedded JavaScript function CheckTourAvailability() that does window.open('file2.php?parameters=values) but when file2.php loads it does not have the object I need in file1.php and using include() in previous thread doesn't seem to work because it causes file1 load and file2.

All I need to find out is if I can call PHP function 'onClick' and pass Javascript values to it.

Thank you,
Victor.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Nope. Not without more help from Javascript.
User avatar
PHPycho
Forum Contributor
Posts: 336
Joined: Fri Jan 06, 2006 12:37 pm

Post by PHPycho »

PHP cant be envoked on click events, Rather use javascript which in itself may contain the PHP functions..
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

Ajax anyone?
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

explaining ajax to a newb as just "ajax" maybe a bit pointless, lol
you can basically call another php script with a function in to aquire the desired result using javascript to fetch the results.
http://www.hunlock.com/blogs/Snippets:_Synchronous_AJAX
Post Reply