PDA

View Full Version : SELECT tag DropDown display changed


rparmar
11-07-2002, 04:04 PM
Q: I have a DropDown-Box as below:-
<SELECT id=selNAMES NAME=selNAMES>
<OPTION selected value=""></OPTION>
<OPTION value="John Smith">1 John Smith</OPTION>
<OPTION value="Alvin Kyle">2 Alvin Kyle</OPTION>
</SELECT>

when user selects one of the two name options;
it shold ONLY display John Smith not the number 1 and
likewise if user chooses option 2; it should only
display Alvin Kyle;

DropDown optins remain the same (as above with number 1 & 2)

Thank you.

kdjoergensen
11-07-2002, 06:40 PM
<SELECT id=selNAMES NAME=selNAMES onchange="this.options[this.selectedIndex].value=((this.options[this.selectedIndex].value).substring(2))">

rparmar
11-08-2002, 05:30 PM
<SELECT id=selNAMES NAME=selNAMES onchange="this.options[this.selectedIndex].value=((this.options[this.selectedIndex].value).substring(2))">

the above did not work;
I changed it to
<SELECT id=selNAMES NAME=selNAMES onchange="this.options[this.selectedIndex].text=((this.options[this.selectedIndex].text).substring(2))">
and it works fine except that dropdown options are loosing 1 and 2 numbers as well when i click again to choose another option;

THX.
RAJ

kdjoergensen
11-08-2002, 05:35 PM
Try:

onchange="this.options[this.selectedIndex].value=(this.options[this.selectedIndex].value)">

The substring(2) is what removed the numbers 1,2 (I thought that was what you were after ??)

rparmar
11-08-2002, 05:46 PM
the value in the select tag is ok; ie without the numbers;
the text displayed of the selected option needs to be removed when chosen; but the dropdown text remains tha same ie. the text property of the select tag should have numbers although the display does not show the numbers of text(not value)

THX

kdjoergensen
11-08-2002, 05:53 PM
Ok, sorry, I now understand. Yes, you are correct. The property should then be .text instead of .value. You are absolutely correct.
Great job..

rparmar
11-08-2002, 06:09 PM
Ok so now the problem is the display shows OK (without numbers); but the dropdown options are without numbers since we substringed it;
the problem not solved!
dropdown should have number(.text); display as we know are without numbers;

THX

scoutt
11-08-2002, 06:23 PM
this is going to sound stupid but bare with me, just take the number out :P

<OPTION value="John Smith">John Smith</OPTION>
<OPTION value="Alvin Kyle">Alvin Kyle</OPTION>

why have the numbers, people know how to count, if you are placing the numbers there for a reason, like a placement value (who came in first place and who was runner up scenerio) and you are loading them from a DB jsut make it so the order is by a certain thing.

rparmar
11-08-2002, 06:37 PM
THX.
Super furry guru for your interest in this !!!!

The reason is that you can use 1 or 111 to go to 111 direct from keyboard;
but more importantly this is used for select element being populated by recordset from two fields of database; field1 being the number associated with username; ie userid; and field2 is the username itself; Problem is that if i have another field (userid) to populate it based on user dynamically at clientside all i have to do is select the option with number(userid) and USerID field will populate itself before submitting; nobody likes to type in the use ids etc...
THX