Solved

Select Option Value

Posted on 2014-11-20
7
138 Views
Last Modified: 2014-11-20
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
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40455552
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
 

Author Comment

by:Richard Korts
ID: 40455597
Gary,

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

Thanks
0
 
LVL 58

Expert Comment

by:Gary
ID: 40455607
Yep
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Richard Korts
ID: 40455806
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
 
LVL 58

Expert Comment

by:Gary
ID: 40455853
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
 

Author Comment

by:Richard Korts
ID: 40455910
So the value, if unspecified, would be null?
0
 
LVL 58

Expert Comment

by:Gary
ID: 40455944
Yep
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

632 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question