SunQuest
           HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 13th, 2000, 10:40 AM
puq puq is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 3 puq User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to puq
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



Reply With Quote
  #2  
Old July 13th, 2000, 02:20 PM
billyo billyo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 114 billyo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 9
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).]

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Text swapping...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway