Page 1 of 1

Dropdown box, how do I get a numerical value for the option

Posted: Sat Dec 09, 2006 6:09 pm
by Mythic Fr0st
How does one get the numerical value of the selected option from a dropdown box...

E.G

you select "dark elf" 3rd in the list, how do I get that to return 3?

so basically

Im loading all the little elfies into a array,

then I need to set $ea=(numerical value for the thingy)

then i'd just use

$_SESSION['MLmon']=$ea;

this is the current form code I have for the options and so on

Code: Select all

<form method="post" action="HomePIG.php">
<select name="monsters">
<option value="Baby Elf">Baby Elf</option>
<option value="Wood Elf">Wood Elf</option>
<option value="Dark Elf">Dark Elf</option>
<option value="Blood Elf">Blood Elf</option>
</select>
<input type='hidden' name='nf' value='nf2'>
<input type="submit" value="New Fight">
</form>
<?php

Posted: Sat Dec 09, 2006 6:10 pm
by feyd
Set the value attribute to three.

hmm

Posted: Sat Dec 09, 2006 7:13 pm
by Mythic Fr0st
hmm, I was thinking I cant do that, because I couldnt refer to my monsters, but if I make an array, and use the value for the post thingy, for it it'd work

Thanks

Posted: Mon Dec 11, 2006 9:55 am
by pickle
I think the Javascript function indexOf() would be helpful.