Solved

Select Option Value

Posted on 2014-11-20
7
137 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 

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

Technology Partners: 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

Suggested Solutions

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn how to count occurrences of each item in an array.

710 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