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:
  Checking Multiple Forms on a Sngle Page  LETMO at 00:16 on Monday, October 30, 2006
 

I have a PHP script which generates an (unknown) number of forms on a single page. Upon clicking I want a simple javascript check function along the lines of:

function submitform()
{
var con=confirm("Do you really want to do this?");
if(con==true)
{
document.form1.submit();
}
else
{
window.location="payment.php";
}


(The actual check is always the same) Obviously, in PHP I can generate the form so that they have different names:
<form name="form<?=$formnumber?>" method="POST" action="payment_action.php"> and/or <a href="javascript: submitform(form<?=$formnumber?>)">Payment</a>, but I am unsure of how to chage the javascript to cope with this.

Thanks in advance,

LETMO

  Re: Checking Multiple Forms on a Sngle Page  David Bruce at 21:36 on Tuesday, October 31, 2006
 

letmo - You could pass in the form name into the function, as in


function submitform(formname)
{
var con=confirm("Do you really want to do this?");
if(con==true)
{
document(formname).submit();
}
else
{
window.location="payment.php";
}

David Bruce: site expert
CodeToad.com


  Re: Checking Multiple Forms on a Sngle Page  LETMO at 04:00 on Thursday, November 02, 2006
 

The problem with this (I think) is that I don't know how many forms there are. I tried generating the form names in php i.e. form1, form2, form3 etc. and then having more than enough Javascript functions i.e.
function submitform(form1)
function submitform(form2)
function submitform(form3)
etc.

But if the form doesn't exist (form5 for example), I get an error & none ofthe submitforms work.



  Re: Checking Multiple Forms on a Sngle Page  LETMO at 05:50 on Monday, November 06, 2006
 

bump








CodeToad Experts

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








Recent Forum Threads
• Re: Insert Contents of .txt file into a .html page
• Re: Perl regular expression problem.
• Re: Problems in login using WWW::Mechanize
• searching for gd::graph guide
• Re: ARRAY OF HASHMAPS
• Adv. Regexp or Otherwise
• Adv. Regexp or Otherwise
• I need help pleasee! My project is about using I/o Stream
• Help Running VB script in Windows 2003


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