Forum Moderators: open

Message Too Old, No Replies

Changing text ion a page from a drop down

Changing text ion a page from a drop down

         

The_Cheese

12:54 pm on Jan 4, 2005 (gmt 0)

10+ Year Member



Please someone help me with this, I want to change some text on a webpage with the use a drop down menu.

The code I have so far is....

<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="dealerships"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><select name="selectbox" size="1" onChange="changecontent(this)">
<option selected value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><br>
</td>
</tr>
<tr>
<td width="100%">

<!-- content to appear here -->

</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<script language="JavaScript">
var thecontents=new Array()
thecontents[0]='ddd'
thecontents[1]='1'
thecontents[2]='2'
thecontents[3]='3'
function changecontent(which){
document.dealerships.contentbox.value=thecontents[which.selectedIndex]
}
document.dealerships.contentbox.value=thecontents[document.dealerships.selectbox.selectedIndex]
</script>

but I am now stuck at outputting the text.

Would appreciate it

adni18

1:50 pm on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Replace the <!-- --> tag with

<input type="text" id="contentbox" value="">

The_Cheese

2:41 pm on Jan 4, 2005 (gmt 0)

10+ Year Member



Cheers but do you know how to do it with HTML text and NOT an input box?

Cheers

adni18

2:48 pm on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="dealerships"><table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><select name="selectbox" size="1" onChange="changecontent(this)">
<option selected value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select><br>
</td>
</tr>
<tr>
<td width="100%">

<SPAN id="dispText"></SPAN>

</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
<script language="JavaScript">
var thecontents=new Array()
thecontents[0]='ddd'
thecontents[1]='1'
thecontents[2]='2'
thecontents[3]='3'
function changecontent(which){
document.getElementById("dispText").innerHTML=thecontents[which.selectedIndex]
}
document.getElementById("dispText").innerHTML=thecontents[document.dealerships.selectbox.selectedIndex]
</script>

The_Cheese

3:02 pm on Jan 4, 2005 (gmt 0)

10+ Year Member



Thanks alot your an absolute STAR!

adni18

6:22 pm on Jan 4, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Any time.