Reputation: 125
i wrote a html code. here i created a form inside which some rows are to be display and a table. Everything is fine but the table does not display in the browser. can you please help me. thanks in advance.
the code is:
<form>
<div id="formWrap">
<h1 align="center" style="color:#0000FF" >B.E. Degree Course Registration</h1>
<div id="form">
<div class="row">
<div class="label0" style="color:#FF0000; font-style:italic; margin-left:20px; font-size:18px">Personel details:</div>
</div> <!-- end of 0th row -->
<div class="row">
<div class="label">Name</div>
<div class="input">
<input type="text" id="fullname" required="required" class="detail" name="fullname" />
</div>
<div class="label">Sex</div>
<div class="inputradio">
<input type="radio" id="radio" required="required" class="detailradio" name="sex" />
<span class="style7">Male</span>
<input type="radio" id="sex" required="required" class="detailradio" name="sex" />
<span class="style7">Female </span></div>
</div> <!-- end of first row -->
<div class="label3">ECA</div>
<div class="inputeca">
<select name="eca">
<option id="eca" required="required" class="ecadetail" value="eca1">NSS</option>
<option id="eca" required="required" class="ecadetail" value="eca2">NCC</option>
<option id="eca" required="required" class="ecadetail" value="eca3">Cultural</option>
</select>
</div>
<div class="label3">Year</div>
<div class="inputyear">
<script language="JavaScript"> <!-- start JS code hide
// loop to create the list
var year = 2012
document.write("<select name='years'>");
for (var i=1; i <=200; i++)
{
year++;
document.write("<option>" + year + "</option>");
}
// end JS code hide -->
</script>
<p></p>
</div>
</div> <!-- end of row -->
<table width="600" border="2">
<tr>
<td>col1</td>
<td>col2</td>
<td>col3</td>
<td>col5</td>
<td>col6</td>
</tr>
</table>
<div class="row">
<div class="submit" style="margin-left:708px">
<input type="submit" id="submit" name="submit" value="Proceed"/>
</div>
</div>
</div>
</div>
</form>
Upvotes: 0
Views: 152
Reputation: 323
You forgot to close the select tag
<script language="JavaScript"> <!-- start JS code hide
// loop to create the list
var year = 2012
document.write("<select name='years'>");
for (var i=1; i <=200; i++)
{
year++;
document.write("<option>" + year + "</option>");
}
document.write("</select>");
// end JS code hide -->
</script>
Check here http://jsfiddle.net/ZHdqK/
Upvotes: 0
Reputation: 15429
Your script is just not closing the select element so the table was inside the select.
<script language="JavaScript"> <!-- start JS code hide
// loop to create the list
var year = 2012
document.write("<select name='years'>");
for (var i=1; i <=200; i++)
{
year++;
document.write("<option>" + year + "</option>");
}
document.write("</select>")
// end JS code hide -->
That should do the trick.
Upvotes: 0
Reputation: 12611
Change:
<script language="JavaScript"> <!-- start JS code hide
// loop to create the list
var year = 2012
document.write("<select name='years'>");
for (var i=1; i <=200; i++)
{
year++;
document.write("<option>" + year + "</option>");
}
// end JS code hide -->
</script>
To
<select name="years">
<script language="JavaScript">
// loop to create the list
var year = 2012
for (var i=1; i <=200; i++)
{
year++;
document.write("<option>" + year + "</option>");
}
// end JS code hide -->
</script>
</select>
You don't need to start the select
tag with JS, and you forgot to close the tag so the table wouldn't show (as well as other stuff, probably).
Upvotes: 2