470,619 Members | 2,062 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,619 developers. It's quick & easy.

How to submit dynamically generated hidden forms

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

Aug 9 '05 #1
6 1865
On Tue, 09 Aug 2005 08:50:59 -0700, P wrote:
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


submit() function.

http://www.javascript-coder.com/java...m-submit.phtml

--
"Blessed is he who expects nothing, for he shall never be disappointed."
Benjamin Franklin (I didn't know he was a Buddhist)

Aug 9 '05 #2
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();
}

Aug 9 '05 #3
On Tue, 09 Aug 2005 10:16:08 -0700, P wrote:
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.

--
"Blessed is he who expects nothing, for he shall never be disappointed."
Benjamin Franklin (I didn't know he was a Buddhist)

Aug 9 '05 #4
P
Yes, you are correct. The function I wrote is not valid. But is it
possible to do something similar?

Aug 9 '05 #5


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();
}

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 9 '05 #6
P
aaaah, I see. Thanks Martin :)

Aug 9 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Phillip Windell | last post: by
8 posts views Thread by Bob Bedford | last post: by
4 posts views Thread by Ike | last post: by
8 posts views Thread by horos | last post: by
1 post views Thread by gzannd | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.