RIRedinPA Posted August 28, 2008 Share Posted August 28, 2008 if i am using javascript to create and populate a form and then want another script to get the values of that form how would I go about doing it? for example: function makeform() { var theform = "<form name='form1'><textarea name='ta1' rows='10' cols='20'>This is the content</textarea><p><a href='javascript void(0);' onClick='getformvalues();'>Submit</a>"; document.getElementById('formholder').innerHTML = theform; document.getElementById('formholder')style.display = "block"; } function getformvalues() { alert(document.getElementById('ta1').value); } I get nothing in the alert and the error console shows document.getElementById('ta1') as being null. Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 28, 2008 Share Posted August 28, 2008 it's because neither of those elements have an id set. either set the id (preferable), or use the name directly to access them. Quote Link to comment Share on other sites More sharing options...
RIRedinPA Posted August 28, 2008 Author Share Posted August 28, 2008 Duh! Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.