Please help! I have a form with checkboxes. When one or more checkboxes are clicked, I want the program to dynamically create a div, assign that div an editable text area, then when user clicks submit, I need it to gather the input from EACH textbox and output that to another textbox. I can't figure out what I'm doing wrong. It always tells me "Object Expected" on clicking the checkboxes. If I have it completely wrong, Please bear with me - I'm still learning! :)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Text Formatter</title>
<script type="text/javascript">
<!--
function checkIt()
{
// Gather dynamically created textbox based on id and assign output to textstring
for (i=0;i<5;i++) {
var box1=document.getElementById('mytext'[i])
if (box1.value){
textstring += box1.value + '\n';
}
}
document.forms['example'].output.value = textstring;
}
function changeIt()
{
//Create textbox within div 'appndiv' and add number to the name based on which box
//selected it
for (var i=0;i<document.forms['example'].ipinfo.length;i++) {
if (document.forms['example'].ipinfo[i].checked) {
var newdiv = document.forms['example'].createElement('div');
var mydiv = "my_div" + [i];
newdiv.id=mydiv;
newdiv.innerHTML = '<br>Please copy and paste additional information here<input type='textarea' id=''mytext' +i')>';
document.getElementById('appndiv').appendChild(newdiv);
}
}
}
// -->
</script>
</head>
<body vlink="blue">
<h2>Text Formatter</h2>
<form name="example">
<table class="form">
<tr>
<td>IP information Gathered From:</td>
<td><input type="checkbox" name="ipinfo"/>Portal<br />
<input type="checkbox" name="ipinfo" onclick="changeIt()" />Ping<br />
<input type="checkbox" name="ipinfo" onclick="changeIt()" />Trace Route<br />
<input type="checkbox" name="ipinfo" onclick="changeIt()" />Whois Lookup<br />
<div id="appndiv"></div>
</tr>
<tr><tr><td><br><br></td></td></tr>
<tr><td colspan="2"><input type="button" action="#" onclick="checkit(); return false" value="Submit form" />
<tr><tr><td><br><br></td></td></tr>
<tr><td colspan="2"><textarea cols="50" rows="25" name="output">When you hit 'Submit' the user input will be written to this text area</textarea></td></tr>
</table>
</form>
</body>
</html>