I
Italio Novuas
Hi all, let me begin by saying that I *ALMOST* have this complete!
What I'm trying to do is make it so my text area shows the innerHTML
of any select item with the same value. For example, if I have a
select list with 5 options:
<select name="select" onChange="changeValues();">
<option value="1">Option 1</option>
<option value="1">More stuff on option 1</option>
<option value="1">EVEN more option one stuff!!</option>
<option value="2">Option 2</option>
<option value="2">Some more option 2 stuff</option>
</select>
<textarea name="testimonialText" cols="45" rows="10">I'm merely a text
area.</textarea>
If a user selects option 1, then I would like all of the option 1
stuff to appear within the text area.
The code I have seems to *almost* be working properly, but if someone
could lend me a hand and point out what I'm doing wrong, it would be
VERY much appreciated.
Here's what I have so far:
function changeValues() {
var e = document.getElementById('select')
[document.getElementById('select').selectedIndex].innerHTML;
var en = e.replace(" ", '');
var s = en.replace("&", '&');
//document.myform.testimonialText.value =s;
var myOptions;
for (myOptions=0; myOptions < window.document.myform.select.length;
myOptions++)
{
var se = document.getElementById('select')[myOptions].innerHTML;
if (window.document.myform.select.options[myOptions].value ==
window.document.myform.select.options[myOptions+1].value ) {
// alert(document.myform.select.options[myOptions].innerHTML);
document.myform.testimonialText.value =
document.getElementById('select')
[document.getElementById('select').selectedIndex].innerHTML;
} else {
//alert("no");
}
}
//alert(en);
}
Thank you for your help!
What I'm trying to do is make it so my text area shows the innerHTML
of any select item with the same value. For example, if I have a
select list with 5 options:
<select name="select" onChange="changeValues();">
<option value="1">Option 1</option>
<option value="1">More stuff on option 1</option>
<option value="1">EVEN more option one stuff!!</option>
<option value="2">Option 2</option>
<option value="2">Some more option 2 stuff</option>
</select>
<textarea name="testimonialText" cols="45" rows="10">I'm merely a text
area.</textarea>
If a user selects option 1, then I would like all of the option 1
stuff to appear within the text area.
The code I have seems to *almost* be working properly, but if someone
could lend me a hand and point out what I'm doing wrong, it would be
VERY much appreciated.
Here's what I have so far:
function changeValues() {
var e = document.getElementById('select')
[document.getElementById('select').selectedIndex].innerHTML;
var en = e.replace(" ", '');
var s = en.replace("&", '&');
//document.myform.testimonialText.value =s;
var myOptions;
for (myOptions=0; myOptions < window.document.myform.select.length;
myOptions++)
{
var se = document.getElementById('select')[myOptions].innerHTML;
if (window.document.myform.select.options[myOptions].value ==
window.document.myform.select.options[myOptions+1].value ) {
// alert(document.myform.select.options[myOptions].innerHTML);
document.myform.testimonialText.value =
document.getElementById('select')
[document.getElementById('select').selectedIndex].innerHTML;
} else {
//alert("no");
}
}
//alert(en);
}
Thank you for your help!