onchange help

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
Jr
Forum Commoner
Posts: 99
Joined: Mon Mar 07, 2005 3:25 pm

onchange help

Post by Jr »

I have an <select> <option> box that changes a maxlength 'onchange' so it uses the 'value' to determine what the maxlength should be. My problem is that i need to actually print/show the value after the form is submitted but all i can do is print php?switch_length=nothing and that's obviously not what i want to print. Does anyone know how i can print the 'name' of the option or have two values in one option or something?

Code: Select all

print &quote;<SELECT name='contact_name' ONCHANGE='location = this.options&#1111;this.selectedIndex].value;'>&quote;;
	print &quote;<option name='' VALUE='contact.php?switch_length=nothing' $select_nothing></option>&quote;;
	print &quote;<option name='Jéréme' VALUE='contact.php?switch_length=jereme_email' $select_jereme_email>Jéréme(eMail)</option>&quote;;
	print &quote;<option name='Jéréme(Cell)' VALUE='contact.php?switch_length=jereme_cell' $select_jereme_cell>Jéréme(Cell)</option>&quote;;
	print &quote;<option name='Jéréme' VALUE='contact.php?switch_length=webmaster' $select_webmaster>WebMaster</option>&quote;;
print &quote;</select>&quote;;
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

when you run this bit of script what does the html look like.
you know the view->source sort of thing?

phpScott
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

Simply :arrow: this.options[this.selectedIndex].name will give you the name of selected option. ;)
Post Reply