Jump to content

Submit Code


nummer31

Recommended Posts

<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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

<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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :D

can u plz explain

how'd u figure it out?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.