Avatar of Bobo--just_East_of_Madison
Flag for United States of America asked on

Have a menu option selected on page load, possibly by passing a value through the URL


I'd like to pass a value to a web form so that on page load, the menu selection will be made to the predefined value.

For example:

Form on http://www.echoecho.com/htmlforms11.htm below "Settings" defaults to "Butter."
In this example, I'd like to have the menu option be "Milk."

A few caveats:

--I have access to change the code for the page the form is iframed in, but not the form itself.
--I cannot use any third-party software
--I cannot use bookmarklets
--A URL solution is preferred (pass the value in the URL, if possible)


Web DevelopmentWeb Browsers

Avatar of undefined
Last Comment
Derek Jensen

8/22/2022 - Mon
Derek Jensen

Can you use PHP/ASP? Or are you limited to HTML only? HTML doesn't have the capacity to capture form-submitted values on its own; if you are using PHP, you'd have to capture the $_GET['select_name'] (which is the value of the selected option for the select tag named "select_name", NOT necessarily the text displayed in that dropdown), and then as you're building the select, test each value against $_GET['select_id_name'] and, if equal, add 'selected="selected"' to the current option's tag. This will make the same option selected before the form is submitted to still be selected after. :)
That is, of course, assuming you're submitting to the same page. ;-)

Can't use PHP, but I'm not limited to HTML. I can use javascript (json) and jconsole. I'm on Apache Tomcat and I don't have access to the server, so my assumption is that I wouldn't be able to use PHP without tweaking something with the server. I've never seen PHP run on Tomcat without some server-side tweaking. I have used PHP on Apache.
Derek Jensen

ok, well...then you should be good. :) You'll have to do some server-side processing, as JS doesn't have the ability to capture POST & GET params...afaik...
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.


Besides PHP, do  you know of any other client-side scripting that can be used? And that doesn't require changes at the server level?

Anyone else?
Derek Jensen

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question