...

View Full Version : Drop-down box changes text javascript?



tjc19999
12-30-2005, 05:00 AM
I have written this drop-down box so that it will change a picture, i would also like it to change text, or the description of the picture when changed. What I have so far is this:

<img name="test" src="http://www.leviathanpc.net/xasersilver.jpg" height="220" align="left"><form method="POST" name="description">
<p style="text-align: center; margin-left: 5; margin-top: 0">hello</p>
</form>
<p style="text-align: center; margin-left:5; margin-top:0">
<br>
</td>
</tr>
</table>
<div align="left">
<table width="590" height="78" border=0 bgcolor="#000000" style="border-collapse: collapse" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" height="100%">
<form name="dropform">

<p style="margin-left: 10; margin-right: 10; margin-top: 10">

<select name="dropdown" onChange="document.images.test.src=document.dropform.dropdown.options[document.dropform.dropdown.selectedIndex].value" onChange="document.forms.description.text=document.dropform.dropdown.options[document.dropform.dropdown.selectedIndex].text" onclick="document.myform.txt=document.dropform.dropdown.options[document.dropform.dropdown.selectedIndex].value">

<option value="http://www.leviathanpc.net/xasersilver.jpg" text="hello">Thermaltake XaserIII (Silver)</option>

<option value="http://www.leviathanpc.net/xaserblue.jpg" text="hi">Thermaltake XaserIII (Blue)</option>

<option value="http://www.leviathanpc.net/minitaurgreen.jpg" text="hi1">Diabolic Minitaur Green</option>

<option value="http://www.leviathanpc.net/minitaurred.jpg" text="hi2">Diabolic Minitaur Red</option>

<option value="http://www.leviathanpc.net/minitaurblue.jpg" text="hi3">Diabolic Minitaur Blue</option>

</select> </p>

</form>


I believe that the problem is when i refer to the text that i want to change, I'm not sure how to refer to "Hello", "Hi", "Hi1" etc.

Any help would be greatly appreciated.
Thanks!

Pennimus
12-30-2005, 10:15 AM
I think to do this in javascript you'd need to look into incorporating the text into an iframe and then changing the iframe source in the same way that you are changing the image source.

tjc19999
12-30-2005, 10:46 PM
i don't want to neccesarily do this in javascript, if there is a way to do it in html i would rather do it that way, which ever is easier.

tjc19999
12-31-2005, 02:06 AM
My final code is as follows:



<form name="txt">hello</form>
</td>
</tr>
</table>
<div align="left">
<table width="590" height="78" border=0 bgcolor="#000000" style="border-collapse: collapse" cellpadding="0" cellspacing="0">
<tr>
<td width="100%" height="100%">
<form name="dropform">

<p style="margin-left: 10; margin-right: 10; margin-top: 10">

<select name="dropdown" onChange="document.images.test.src=document.dropform.dropdown.options[document.dropform.dropdown.selectedIndex].value, document.getElementById('txt').innerHTML=document.dropform.dropdown.options[document.dropform.dropdown.selectedIndex].value1">

<option value="http://www.leviathanpc.net/xasersilver.jpg" value1="hello">Thermaltake XaserIII (Silver)</option>

<option value="http://www.leviathanpc.net/xaserblue.jpg" value1="hi">Thermaltake XaserIII (Blue)</option>

<option value="http://www.leviathanpc.net/minitaurgreen.jpg" value1="hi1">Diabolic Minitaur Green</option>

<option value="http://www.leviathanpc.net/minitaurred.jpg" value1="hi2">Diabolic Minitaur Red</option>

<option value="http://www.leviathanpc.net/minitaurblue.jpg" value1="hi3">Diabolic Minitaur Blue</option>

</select> </p>

</form>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum