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. Link to comment https://forums.phpfreaks.com/topic/121717-solved-getting-dynamic-form-values/ 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. Link to comment https://forums.phpfreaks.com/topic/121717-solved-getting-dynamic-form-values/#findComment-627899 Share on other sites More sharing options...
RIRedinPA Posted August 28, 2008 Author Share Posted August 28, 2008 Duh! Thanks! Link to comment https://forums.phpfreaks.com/topic/121717-solved-getting-dynamic-form-values/#findComment-627925 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.