|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi all,
I'm sure this is a simple problem, but I'm not very good with javascript and could use some help! I have a form, in this form I have a selection list: <select name="select_list" onChange="swap_text();"> <option value="1">Value 1</option> <option value="2">Value 2</option> <option value="3">Value 3</option> </select> What I would like this to do, is when the user changes the value in the selection list, is to print the option text ie Value 1, Value 2, Value 3...in a table below the selection list. <table> <tr> <td>select_list values</td> </tr> </table> I'm not really sure how to do this. If anyone can provide me with any info, I'd be forever greatful. Thanks |
|
#2
|
|||
|
|||
|
To display value in the table itself, and to have it work in NS and IE would be a little tricky. IE's <td> has the "innertext" property which would make it a snap. For NS you'd have to do something like:
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><table><tr> <script language=JavaScript><!-- function Swap_Text() { document.write("<td>" + value + "</td>") //and I know there's another line you need for NS to keep it from adding to the line the next time you call it. It's something like document.write.close() //but I know that's not it exactly } //--></script>[/code] I think the easiest way to do it would be to use a textbox in your table, and call it "swapped_text" or something. Then say. <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre><script language=JavaScript><!-- var selection_text=new Array selection_text[0]="value zero" selection_text[1]="value one" ... function Swap_Text() { swapped_text.value=selection_text[select_list.value] //just make sure to keep you selection values numeric. }//--></script>[/code] Anyway, something like that would probably work, but the above code is by no means intended to be immediately usable... [This message has been edited by billyo (edited July 13, 2000).] |
![]() |
| Viewing: Dev Shed Forums > Web Design > HTML Programming > Text swapping... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|