How to submit dynamically generated hidden forms

P

P

Hi,

As the subject says, I would like to submit dynamically generated
hidden forms with javascript. I'm fairly new to javascript. I've
googled around but couldn't find a solution. I would appreciate if
someone can point me to the right direction.

Thanks
 
P

P

On the site you've provided, it gave this example:

<form name="myform" action="handle-data.php">
Search: <input type='text' name='query'>
<A href="javascript: submitform()">Search</A>
</form>
<SCRIPT language="JavaScript">
function submitform()
{
document.myform.submit();
}
</SCRIPT>

What I'm hoping to do is to have a function like that, but takes an
argument for the name of the form. This is probably the wrong syntax
but I think it shows what I want to do:

function submitform(formID)
{
document.formID.submit();
}
 
I

Ivan Marsh

On the site you've provided, it gave this example:

<form name="myform" action="handle-data.php">
Search: <input type='text' name='query'> <A href="javascript:
submitform()">Search</A> </form>
<SCRIPT language="JavaScript">
function submitform()
{
document.myform.submit();
}
</SCRIPT>

What I'm hoping to do is to have a function like that, but takes an
argument for the name of the form. This is probably the wrong syntax
but I think it shows what I want to do:

function submitform(formID)
{
document.formID.submit();
}

IIRC the form name isn't a valid object in any browser.

I think the submit function has to be called in the body of the form...
but I may be wrong about that.
 
P

P

Yes, you are correct. The function I wrote is not valid. But is it
possible to do something similar?
 
M

Martin Honnen

P wrote:

function submitform(formID)
{
document.formID.submit();


If the form has an id attribute and you pass its value in as the formID
parameter then you can use
var form;
if (document.getElementById && (form =
document.getElementById(formID))) {
form.submit();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top