nummer31 Posted May 8, 2010 Share Posted May 8, 2010 <a href="#" onClick="document.getElementById('form1').submit()" style="margin-left:10px">send</a> i'm used to submitting forms with buttons <input type="submit" name="button" id="button" value="Submit" /> can smn plz explain me the top codes? and i can't make the code to work with a form for submitting values some pointers will be appreciated Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 8, 2010 Share Posted May 8, 2010 are you sure that you have "form1" as the ID on that form? Also, if that <a> is inside the form, you could do this: <a href="#" onClick="this.form.submit()" style="margin-left:10px">send</a> Quote Link to comment Share on other sites More sharing options...
nummer31 Posted May 10, 2010 Author Share Posted May 10, 2010 <a href="#" onClick="this.form.submit()" style="margin-left:10px">send</a> ur code doesn't work either This is the code for the form inside the table the 'reset' works but the 'submit' doesn't <table > <tr> <td style="width:136px;" align="right"> <br style="line-height:7px"> Your Full Name Here:<br> <br style="line-height:14px"> Your E-mail Address:<br> <br style="line-height:14px"> Comments & Questions: </td> <td style="width:13px;"></td> <td style="width:169px;"> <form id="form1" action="" name="form1" method = "post"> <div class="form"><input type="text" name="name" id="name"></div> <div class="form"><input type="text" name="email" id="email"></div> <textarea rows="40" cols="50" name="message" id="message"></textarea><br> <br style="line-height:9px"> <span > <a href="#" onClick="document.getElementById('form1').reset()" style="margin-left:52px">clear</a> <a href="#" onClick="document.getElementById('form1').submit()" style="margin-left:10px">send</a> </span> <label> <input type="submit" name="Submit" id="Submit" value="Submit"> </label> </form> </td> </tr> </table> Quote Link to comment Share on other sites More sharing options...
n000bie Posted May 10, 2010 Share Posted May 10, 2010 What should happen after you click the submit button (save the data or display it on the page) ? Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 10, 2010 Share Posted May 10, 2010 What happens if you try this: <table > <tr> <td style="width:136px;" align="right"> <br style="line-height:7px"> Your Full Name Here:<br> <br style="line-height:14px"> Your E-mail Address:<br> <br style="line-height:14px"> Comments & Questions: </td> <td style="width:13px;"></td> <td style="width:169px;"> <form id="form1" action="" name="form1" method = "post"> <div class="form"><input type="text" name="name" id="name"></div> <div class="form"><input type="text" name="email" id="email"></div> <textarea rows="40" cols="50" name="message" id="message"></textarea><br> <br style="line-height:9px"> <span > <a href="#" onClick="document.getElementById('form1').reset()" style="margin-left:52px">clear</a> <a href="#" onClick="document.getElementById('Submit').click()" style="margin-left:10px">send</a> </span> <label> <input type="submit" name="Submit" id="Submit" value="Submit"> </label> </form> </td> </tr> </table> The difference is that the submit <a> virtually clicks the submit button. If you then want to hide the submit button, hide it with CSS. Quote Link to comment Share on other sites More sharing options...
nummer31 Posted May 10, 2010 Author Share Posted May 10, 2010 What happens if you try this: <table > <tr> <td style="width:136px;" align="right"> <br style="line-height:7px"> Your Full Name Here:<br> <br style="line-height:14px"> Your E-mail Address:<br> <br style="line-height:14px"> Comments & Questions: </td> <td style="width:13px;"></td> <td style="width:169px;"> <form id="form1" action="" name="form1" method = "post"> <div class="form"><input type="text" name="name" id="name"></div> <div class="form"><input type="text" name="email" id="email"></div> <textarea rows="40" cols="50" name="message" id="message"></textarea><br> <br style="line-height:9px"> <span > <a href="#" onClick="document.getElementById('form1').reset()" style="margin-left:52px">clear</a> <a href="#" onClick="document.getElementById('Submit').click()" style="margin-left:10px">send</a> </span> <label> <input type="submit" name="Submit" id="Submit" value="Submit"> </label> </form> </td> </tr> </table> The difference is that the submit <a> virtually clicks the submit button. If you then want to hide the submit button, hide it with CSS. thank u very much it works just fine i copy pasted this part: <a href="#" onClick="document.getElementById('Submit').click()" style="margin-left:10px">send</a> and it worked can u plz explain how'd u figure it out? Quote Link to comment Share on other sites More sharing options...
F1Fan Posted May 11, 2010 Share Posted May 11, 2010 Well, I know that clicking a submit button in a form will submit that form. So, I used the click() function to simulate clicking that submit button. I figured that out a while back when trying to figure out a way to call a JavaScript function that is on one page from another page, usually in a form. 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.