void Posted September 25, 2009 Share Posted September 25, 2009 hi guys, I've come across an issue. looks like if I add an input field in a simple way, that is, appending html code of a field to innerHTML on a div, it doesn't actually create an element. it appears visually, but if i submit the form, there is no sign of that field. any ideas why could that be? thanks. Quote Link to comment Share on other sites More sharing options...
yettti Posted September 25, 2009 Share Posted September 25, 2009 A common one would be that your using the same id ... for example do detail[0] detail[1] detail[2] Quote Link to comment Share on other sites More sharing options...
.josh Posted September 27, 2009 Share Posted September 27, 2009 alternatively, try using createElement and appendChild Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted September 27, 2009 Share Posted September 27, 2009 What exactly do you mean with "it appears visually"? Does it show a new input field when you're appending html code of a field to innerHTML. Could you post the code that you're using to create the a new field? Another note, once you submit your form the text fields you create using javascript won't be rebuild on the form unless you've handle this serverside somehow. Quote Link to comment Share on other sites More sharing options...
void Posted December 19, 2009 Author Share Posted December 19, 2009 Okay, I'm back to this problem. Thanks for your replies. Here's the thing. I have something like: <form action="" method="post"> <div id="extra"> </div> <input type="text" name="something" value="test" /> <input type="submit" name="submit" value="Submit!" /> </form> So let's say I call this javascript function from somewhere: document.getElementById('extra').innerHTML = '<input type="text" name="field1" value="" />'; The text field appers on a page, but if I enter some text and submit the form, it doesn't post the info from that field. For example, if I do print_r($_POST); I see [field1] => [something] => test. Any idea what's the problem? Quote Link to comment Share on other sites More sharing options...
void Posted December 20, 2009 Author Share Posted December 20, 2009 nevermind - turns out the <form> tag wasn't in the correct place. took me forever to figure out, especially since it worked perfectly on IE. 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.