Jump to content

insert row onclick


phpgoal

Recommended Posts

Hello,

 

I want to insert a row after i click the submit button but no rows get inserted.

 

Please help me!

 
<!DOCTYPE html><html><head><script>
window.onload = function(){    var selectElement = 
document.getElementById('animal');    var selectMonth = 
document.getElementById('month1');    
document.getElementById('year').onsubmit = 
function(){      var index = 
selectElement.selectedIndex;        var 
indexM = selectMonth.selectedIndex; var ff = 
selectElement.options[index].value;         
var mm = selectMonth.options[indexM].value;
    };
};
function displayResult(){
for($row=0; $row<1; $row++){var 
table=document.getElementById("myTable");var 
row=table.insertRow($row);var cell1=row.insertCell(0);var 
cell2=row.insertCell(1);cell1.innerHTML="tt";cell2.innerHTML="mm";}
}</script></head><body>
<form id="year" action="#"><table border = 
"2"><tr><td> <strong>Select Year</strong> 
</td> <td> <strong>Select Month 
</strong></td>  
</tr><tr><td>    <select id="animal" 
name="animal" 
class="favAnimal">        <option 
value="2013">2013</option>        
<option 
value="2012">2012</option>           
</select></td><td> <select id="month1" 
name="animal" 
class="favAnimal">        <option 
value="Jan">January</option>        
<option 
value="Feb">Feb</option>        
<option value="Mar">Mar</option>    
</select></td> </tr>  <tr> <td colspan = 
"2"> <input type="submit"  onclick="displayResult();" value="Submit" 
/></td></tr></table></form>
<br>
<table id="myTable" border="1"><tr> 
<td><b>year</b> </td> <td> 
<b>month</b></td> 
</tr></table><br>
</body></html>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.