toreachdeepak Posted June 3, 2009 Share Posted June 3, 2009 Hi,I have a javascript functionfunction dist2(value1,value2){ var des = "description"; for(m=value1;m<value2;m++) { document.write(document.getElementById(des+m)+"<BR>"); } return false;}The id's of the text area are built as given below==================================for($i=0;$i<5;$i++) {<textarea rows="3" cols="35" id="<?php echo 'description'.$i?>"name="<?php echo 'description'.$i?>"></textarea>}The dist2 javascript function is called as given below======================================<input type="submit" name="save" onClick="if(dist2(0,5) == false) return false; else return true;"value="Save/Add More">I am getting the following reply====================[object HTML TextArea Element]nullnullnullnull Link to comment Share on other sites More sharing options...
jeffman Posted June 3, 2009 Share Posted June 3, 2009 When you use document.write() AFTER a page has loaded, it destroys the current document and creates a new one. So this function is able to access the first textarea, but after it uses document.write() the first time, the other textareas no longer exist.If you don't want to use alert() to report a bunch of data, you can change the innerHTML of some page element that exists just for this purpose. Or in this case, you could write the information to the value property of one of your textareas. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.