optikalefx Posted September 1, 2007 Share Posted September 1, 2007 Ive been trying for a while and nothing is working so i have this html <select> statement I have a submit button as well. As it is now, you select from the list, and hit the submit button, which sends the info that was selected as well as a hidden variable. Now what I really need, is to execute that submit button with an onchange of the select statement. But that would mean it would no long use the submit, therefore not execute the form action, therefore not sending the value of the selected. Is there a onchange(this.selected) to send to a javascript function which will execute a php header:location with the correct variables in the url to get in the next page? In short, I want you to click an option in the drop down and it takes you to the next page with that selected info. Quote Link to comment https://forums.phpfreaks.com/topic/67545-php-javascript-and-sending-variables/ Share on other sites More sharing options...
Ken2k7 Posted September 1, 2007 Share Posted September 1, 2007 Uh, well you don't need PHP at all for this. Javascript is well capable of redirecting the user. As for the selected info, add that to the url and get it with php Quote Link to comment https://forums.phpfreaks.com/topic/67545-php-javascript-and-sending-variables/#findComment-339185 Share on other sites More sharing options...
optikalefx Posted September 1, 2007 Author Share Posted September 1, 2007 there is a need for a little bit of php which im not sure how to implement i have this function that is excecuted onchange function change() { var mylist=document.getElementById("myList") var JSVar = mylist.options[mylist.selectedIndex].text window.location = "http://www.4tenonline.com/newupdatetextarea.php?user=<?PHP $user ?>&pagechoice=JSVar" target="main" } 2 questions 1: can i do that <?PHP $user ?> 2: (idk if you can answer this here) is that you how you include a javascript variable in a url? just the name of the variable &pagechoice=JSVar Quote Link to comment https://forums.phpfreaks.com/topic/67545-php-javascript-and-sending-variables/#findComment-339194 Share on other sites More sharing options...
optikalefx Posted September 1, 2007 Author Share Posted September 1, 2007 ok so i know for sure you cant do what i just tried to do. Im trying to find a way to now to use javascript to get a certain php variable, to go to the link with those values see above Quote Link to comment https://forums.phpfreaks.com/topic/67545-php-javascript-and-sending-variables/#findComment-339206 Share on other sites More sharing options...
optikalefx Posted September 1, 2007 Author Share Posted September 1, 2007 got it, woooo I use onchange to execute a javascript function that function used ID's to get the selected value and store it to a variable Then i stored my PHP variable as a Javascript variable Then created a variable string of the URL with the selected variable and PHP variable then i used window.parent.framename.location to execute that variable string Quote Link to comment https://forums.phpfreaks.com/topic/67545-php-javascript-and-sending-variables/#findComment-339233 Share on other sites More sharing options...
pyrodude Posted September 1, 2007 Share Posted September 1, 2007 Sorry, apparently I was a day too late. Your previous post was very close. Yes, you can use <?php ?> tags anywhere. However, you either need to use <?=$var; ?> or <?php echo $var; ?> in order to output the contents of a variable to the current page. Quote Link to comment https://forums.phpfreaks.com/topic/67545-php-javascript-and-sending-variables/#findComment-339281 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.