Preserved Topic: javascript: two variables in value-tag (Page 1 of 1) |
|
---|---|
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 12-10-2001 21:37
ok, i got a <SELECT> with a lot of <OPTION VALUE=... NAME=...> which are dynamically generated by php. |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
posted 12-10-2001 21:43
The poster has demanded we remove all his contributions, less he takes legal action. |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 12-10-2001 21:55
You could also do something like have the php output a javascript array of corresponding values that you can index |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 12-10-2001 22:07
ini, that's a nice idea, but it wont work since one of the values is an url. and it already contains : and i dont wanna program a text parser that filters all that out. |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 12-10-2001 23:14
uhhhh i just found a very elegant solution myself: code: <INPUT type="button" value="Insert Linkcode" onClick="addText(document.editmenu.links.value,document.editmenu.links.options[document.editmenu.links.selectedIndex].text)">
|
Paranoid (IV) Inmate From: Sthlm, Sweden |
posted 12-11-2001 10:59
Hi. code: <html> |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 12-11-2001 12:22
now that is really interesting! i didnt know that. thanks! |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 12-11-2001 20:16
This is an interesting method, but keep in mind that it's a hack, and not the way style sheets are intended to be used. I mean, it should always work, but it's not really *morally* right to use it. =) |
Bipolar (III) Inmate From: USA! USA! USA! |
posted 12-12-2001 22:47
You could also write script to add "value2" properties to the options when the page loads. The DOM supports getAttribute also, which is the best method if you can stick to the right browsers. |
Paranoid (IV) Mad Scientist From: Omicron Persei 8 |
posted 12-12-2001 23:00
the problem is, i cant. |
Lunatic (VI) Mad Scientist From: Massachusetts, USA |
posted 12-13-2001 20:43
I wish you'd say what you're trying to do, but try making two arrays, where the first element in each array corresponds to the first option in the list, and so on. then, when someone selects an option, read from the arrays. |