Solved

Select Option Value

Posted on 2014-11-20
7
126 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
  • 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now