Avatar of Bobo--just_East_of_Madison
Bobo--just_East_of_MadisonFlag 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
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

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. ;-)
Avatar of Bobo--just_East_of_Madison


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.
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

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...

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?
Avatar of Derek Jensen
Derek Jensen
Flag of United States of America image

Blurred text
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Web Development
Web Development

Web development includes all aspects of presenting content on intranets and the Internet, including delivery development, protocols, languages and standards, server software, browser clients, databases and multimedia generation.

Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews


IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo