I don't know how I would access the value of value="" in the <select> form.
I have this code:
<select name="something" method="post">
<option value="value1">name</option>
<option value="value2">name2</option>
...
...
</select>
now, this select form is inside a form with many more
<select>s and other <input>s with it.
my problem is, how I can access value1,value2 from that certain <select> form through
plain PHP. Do I need to use $_POST?
dumb problem i can't get through.
Moderator: General Moderators
Re: dumb problem i can't get through.
<form method=post>
$_POST['something']
$_POST['something']
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: dumb problem i can't get through.
This wrong. You will need to read up on basic html. This should give you a step in the right direction...<select name="something" method="post">
<option value="value1">name</option>
<option value="value2">name2</option>
Code: Select all
<form action='#' method='post'>
<select name='result1' id='result1'>
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>
</form>Code: Select all
<?php
echo $_POST['result1']; // this will display the option value that the user selected
?>Re: dumb problem i can't get through.
as far as i know,
you can actually create something like this:
Now, I want php to get the value of value=""
and not what's between the <option> tags.
would $_POST['something'] automatically return
what the option's value, for this case,
would it return name?

you can actually create something like this:
Code: Select all
<select name="something">
<option value="name">not name</option>
</select>
and not what's between the <option> tags.
would $_POST['something'] automatically return
what the option's value, for this case,
would it return name?
- jaoudestudios
- DevNet Resident
- Posts: 1483
- Joined: Wed Jun 18, 2008 8:32 am
- Location: Surrey
Re: dumb problem i can't get through.
Try it and see
But yes it would return name. If you dont put value attribute on the option, it will return what is between the option tags, but if you use the value attribute, it will return the value of that - in this case name
But yes it would return name. If you dont put value attribute on the option, it will return what is between the option tags, but if you use the value attribute, it will return the value of that - in this case name
Re: dumb problem i can't get through.
thank you. I was also enlightened by my web programming subject with regard to that very particular detail.jaoudestudios wrote:Try it and see![]()
But yes it would return name. If you dont put value attribute on the option, it will return what is between the option tags, but if you use the value attribute, it will return the value of that - in this case name