We help IT Professionals succeed at work.

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

317 Views
Last Modified: 2013-11-19
Hello:

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)


Thanks,

Bobo
Comment
Watch Question

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

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?
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.