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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

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

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Set the value attribute to three.
Mythic Fr0st
Forum Contributor
Posts: 137
Joined: Sat Dec 02, 2006 3:23 am
Contact:

hmm

Post 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
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

I think the Javascript function indexOf() would be helpful.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply