aaronlzw_21 Posted May 4, 2006 Share Posted May 4, 2006 how do i pass variables into php from javascript? i've tried<script language = "javascript"var valueSelected = frmData.ListLocation.value //this is the value i wan to pass into php"<?php $test= ?>" valueSelected "<?php ; ?>"</script>it gives giving me error. Quote Link to comment Share on other sites More sharing options...
bl0wfish Posted May 4, 2006 Share Posted May 4, 2006 You try to mess php and javascript in an improper way. PHP is parsed and interpreted on the server before javascript is being executed on the client's machine, so you can't directly assign a php variable some value that's generated by javascript. You have to do a separate request by using hidden form fields, then assign these fields some values with javascript and finally you have to submit this form using frmData.submit()Good Luck! Quote Link to comment Share on other sites More sharing options...
GBS Posted May 4, 2006 Share Posted May 4, 2006 Hi,,check for some terms like AJAX/XMLHttpRequest method,, I've recently put an example there: [a href=\"http://www.phpfreaks.com/forums/index.php?showtopic=90550\" target=\"_blank\"]XMLHttpRequest[/a]So, the script sends javascript values to php using the $_POST method, & php part then updates the database, 'saving changes dynamically', without reloading the page,You can do the same thing querying and recuperating some values from php -> javascript without reloading the all page, still using some XMLHttpRequest methods,,Hoping it helps,l8tr,, Quote Link to comment Share on other sites More sharing options...
aaronlzw_21 Posted May 4, 2006 Author Share Posted May 4, 2006 okok i got it thanks guyz! i've changed the way i code. it works for now. thanks gurus! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.