Select Option Value

If you have an HTML select element and an option like <option>--</option> and that is the default one selected, in the php processing program, does it pass "Null" as the value?

That is, is $_REQUEST['select name'] ==  "" ?

Thanks
Richard KortsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GaryConnect With a Mentor Commented:
If "--" is the displayed value then that is what is sent in the post/get
When no value attribute is set then the displayed value is used.
0
 
Richard KortsAuthor Commented:
Gary,

So to get "", I have to say <option value="">--</option>?

Thanks
0
 
GaryCommented:
Yep
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Richard KortsAuthor Commented:
One more thing. If I am doing Javascript edits IN the html page with the form, is the javascript value of the form element "" or "--"?

Thanks
0
 
GaryCommented:
Can be either.
With javascript to get the displayed value you use
.options[e.selectedIndex].text

And to get the option value you use
.options[e.selectedIndex].value
0
 
Richard KortsAuthor Commented:
So the value, if unspecified, would be null?
0
 
GaryCommented:
Yep
0
All Courses

From novice to tech pro — start learning today.