codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Submit button and javascript  gavin101 at 07:44 on Tuesday, November 28, 2006
 

Hi,

I am trying to write a webpage that submits a form to a php file.

It does this in 2 ways, once when the submit button is pressed, and once after a timeout.

I can get the submit button to work and submit the details correctly, however when I post it through
the javascript, document.form.submit I get errors. The first of these error was because I had the form input (to submit the form) called 'submit'.
I changed this, and altough the javascript now executed it didn't update the php correctly. Not only that but the submit button no longer worked.

Is there a way of posting a form in javascript without using the submit function, or is there a way to simulate the user pressing on the submit button. Or something that I'm doing totally wrong!

It looks to me like the php file (which I didn't write or understand) doesn't like it when it isn't sent the value submit. I could be wrong about this though.

Any ideas? (Code below, cut down version)

Thanks,
Gavin

NOTE: I haven't put the timeout code here (and I have put dummy values in), I just the javascript call in the onload funtion for ease of reading.

<HTML>
<HEAD>

<script language="JavaScript">
function submitForm()
{
document.form["name"].value="ee";
document.form["score"].value="15";

document.form.submit();
}
</script>


</head>
<body onload="return submitForm()">

<form name ="form" action="***removed***" enctype="multipart/form-data" method="post">
<input type="text" class="post" name="name" value="" />
<input type="text" class="post" name="score" value="" />
<!-- Line below is not liked by the javascript but has to be there for the php! -->
<input type="submit" name="submit" value="Submit" class="mainoption" />
</BODY>
</HTML>











CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  Re: research the search - hash
•  I want to control Digital Camera or Web Cam through VB
•  Re: Does anyone know to create or implement a diary into Java??
•  Re: Perl Developers Guide
•  Re: Replacing patterns a^b with pow(a,b)
•  Re: java input/output
•  Re: Beanshell web browser
•  Re: dynamic crystal report generation
•  Re: java app auto web update..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007