Click to See Complete Forum and Search --> : document.all.select.innerHTML


Jdvlpr
09-03-2003, 04:44 PM
Please help...... Thanks in advance.

In the following code, I am trying to rewrite the "selection" and "Options"
from within the page:

<html>
<head>
<title> Rewriting the header </title></head>
<body>
<script language=JavaScript>
var mdInnerHTML="";

function rewriteHeader()
{
mdInnerHTML="";
mdInnerHTML+="A newly rewritten Header.";
document.all.header.innerHTML = mdInnerHTML;
// document.all.header.innerHTML = "This is the Rewritten Header.";

}

function rewriteSelection()
{
mdInnerHTML+='<select ID="choices1" Name="choices"
onClick="rewriteSelection()">\n'
mdInnerHTML += '<option value="selection1">Selection1</Option>\n';
mdInnerHTML += '<option value="selection2">Selection2</Option>\n';
mdInnerHTML += '<option value="selection3">Selection3</Option>\n';
mdInnerHTML+="</select>";
// document.all.header.innerHTML = "THis is a Rewritten Header.";
document.all.choices.innerHTML = mdInnerHTML;

}

</script>

<center>
<H1 ID="header" onClick="rewriteHeader()">A Header</H1>
<br>
Click the header once to rewrite it.
</center>

<select ID="choices1" Name="choices" onchange="rewriteSelection()">
<option value="sel1">Sel1</Option>
<option value="sel2">Sel2</Option>
<option value="sel3">Sel3</Option>
<option value="sel4">Sel4</Option>
<option value="sel5">Sel5</Option>
<option value="sel6">Sel6</Option>
</select>

</body>
</html>

Rewriting the header (rewriteHeader()) works, but rewriting the selection
doesn't, it said "runtime error on
"document.all.choices1.innerHTML=mdInnerHTML;"

What am I missing or doing wrong?
Please help.

Many Thanks,
K.

Khalid Ali
09-03-2003, 04:46 PM
take a look at this link,

http://www.webapplikations.com/pages/html_js/forms/CreateDynamicListBox.html

it should help you modify your code accordingly,and you may want to use crossborwser code since document.all is only IE specific.

The link above will have almost everything you need.

Jdvlpr
09-04-2003, 10:12 PM
That was very helpful.... Thanks Khalid.

K.