Page 1 of 1

onchange help

Posted: Thu Apr 28, 2005 1:28 pm
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;;

Posted: Fri Apr 29, 2005 3:35 am
by phpScott
when you run this bit of script what does the html look like.
you know the view->source sort of thing?

phpScott

Posted: Mon May 02, 2005 2:06 am
by n00b Saibot
Simply :arrow: this.options[this.selectedIndex].name will give you the name of selected option. ;)