Gossamer Forum
Home : General : Internet Technologies :

Writing HTML, without document.write in JS :/

Quote Reply
Writing HTML, without document.write in JS :/
Hi guys,

Not sure if anyone can help me :/

Basically - I have this code;

Code:
<html>
<head>
<title>New Page 6</title>
</head>

<body>

<script type="text/javascript">
function makeFormsFields(numberoffields) {
alert('number of fields to make: ' + numberoffields);
for (var i=0; i<numberoffields; i++) {
var newInput = document.createElement('input');
newInput.type = 'text';
newInput.name = 'input' + (i+1);
newInput.size = '20';
newInput.value = 'New input ' + (i+1);
document.forms[0].appendChild(newInput);
}
}
</script>

<form method="POST" action="#">
<p>
<select size="1" name="NumberOfFiles" onchange="makeFormsFields(this.value);">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</p>
</form>
</body>
</html>

This gives a dropdown box, with a text box incrimenting, each "printing" (i.e text1, text2, etc).

My problem comes with this - I need to output a much more advanced set of content :/

i.e (for each one);

Code:
<table border="1" style="border-collapse: collapse" width="47%" id="table1">
<tr>
<td width="153"><b>Document XX</b></td>
<td>&nbsp;</td>
</tr>
<tr>
<td width="153">Level of Document:</td>
<td><select size="1" name="LevelXX">
<option>GCSE</option>
<option>A-Level</option>
<option>I.B</option>
<option>University</option>
</select></td>
</tr>
<tr>
<td width="153">Number of Words:</td>
<td><input type="text" name="NumberOfWordsXX" size="20"></td>
</tr>
<tr>
<td width="153">File:</td>
<td><input type="file" name="FileNameXX" size="20"></td>
</tr>
</table>

I tried document.write, but apparantly that "overwrites" existing content, if run AFTER the page has loaded.

Is what I'm doing even possible? I've hit a bit of a major road block :(

TIA!

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Subject Author Views Date
Thread Writing HTML, without document.write in JS :/ Andy 7892 Jun 4, 2006, 12:35 PM
Thread Re: [Andy] Writing HTML, without document.write in JS :/
dan 7725 Jun 4, 2006, 5:39 PM
Thread Re: [dan] Writing HTML, without document.write in JS :/
Andy 7723 Jun 5, 2006, 12:58 AM
Thread Re: [Andy] Writing HTML, without document.write in JS :/
dan 7688 Jun 5, 2006, 8:01 AM
Thread Re: [dan] Writing HTML, without document.write in JS :/
mkp 7735 Jun 5, 2006, 9:31 PM
Post Re: [mkp] Writing HTML, without document.write in JS :/
dan 7657 Jun 5, 2006, 10:46 PM