How to submit from javascript

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
erbrmn
Forum Newbie
Posts: 3
Joined: Wed Dec 17, 2008 2:39 pm

How to submit from javascript

Post by erbrmn »


There are 2 buttons, I want to submit forum from javascript code.
It is not work, how can I submit when I have several buttons in single forum, please advice me.

Code: Select all

 
<html>
<head>
  <script language="JavaScript">
  <!--
    function funcSubmitform(p_url) {
 
      if (confirm("Really ?"))
      {
        frmMain.action = p_url;
        frmMain.submit();
        return true;
      } else {
        return false;
      }
    }
  //-->
</script>
</head>
<body>
<form method="POST" name="frmMain">
<div align="center">
  <table border="0" width="100%" border="0" cellpadding="6" cellspacing="1">
    <tr>
      <td class="title">ID :</td>
        <td class="item"><input name="txtUserID" value="" tabindex = "1" type="text" size="40" /></td>
    </tr>
    <tr>
      <td height="50" colspan="2" align="center" class="item">
        <input type="button" name="btnREG" value="UPDATE" onclick="funcSubmitform('file1.php');">
        <input type="button" name="btnDEL" value="DELETE" onclick="funcSubmitform('file1.php');">
      </td>
    </tr>
  </table>
</div>
</form>
</body></html>
 
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: How to submit from javascript

Post by John Cartwright »

Try changing

Code: Select all

frmMain.submit();
to

Code: Select all

document.frmMain.submit();
Better yet, google has ALOT to say on the matter
erbrmn
Forum Newbie
Posts: 3
Joined: Wed Dec 17, 2008 2:39 pm

Re: How to submit from javascript

Post by erbrmn »

Yes , I tried like this ,

Code: Select all

document.frmMain.submit();
also I searched from google.com, ..... but I still can not submit.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: How to submit from javascript

Post by John Cartwright »

Does this example work?

Code: Select all

<script language="javaScript">
function SubmitForm()
{
    document.form1.submit();
}
</script>
 
<form name="form1" action="anotherpage.html">
<a href="#" onclick="SubmitForm()">Test Link</a>
</form>
erbrmn
Forum Newbie
Posts: 3
Joined: Wed Dec 17, 2008 2:39 pm

Re: How to submit from javascript

Post by erbrmn »

Jcart:

Thank you for advices, but I still can not submit it when I use normal link.
When I submit to normal html file It can link but not like real submit, I can not submit php file.

Have you any idea?
Post Reply