[SOLVED] Simple form submission question

This is a discussion on "[SOLVED] Simple form submission question" within the JavaScript Forum section. This forum, and the thread "[SOLVED] Simple form submission question are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 13th, 2007, 15:11
New Member
Join Date: Oct 2007
Location: London
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question [SOLVED] Simple form submission question

Hi,

I have what I think should be a simple question.

I'm trying to submit form details to a javascript function using onclick.

The trouble I'm having is because the form is dynamically generated using php I do not know the names of the form fields or how many there will be.

So...

what can I use to say "pass all the form fields to the function"

eg.

onclick="callfunction(myform.allfields_and_values) "


Any help would be appreciated, spent quite a lot of time searching Google for the answer.

Thanks
Reply With Quote

  #2 (permalink)  
Old Oct 13th, 2007, 22:33
Rakuli's Avatar
SuperMember

SuperMember
Join Date: Sep 2007
Location: Australia
Age: 24
Posts: 956
Blog Entries: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Simple form submission question

You could use

Code: Select all
onclick="callfunction(this.form)"
This will pass a refence to the form from which you can cycle through the inputs/elements

Code: Select all
function callFunction (theForm)
{
var inputs = theForm.getElementsByTagName('input');
var selects = theForm.getElementsByTagName('select');

//etc

for (i=0; i<inputs.length; i++)
{
    // Process the inputs
}
for (i=0; i<selects.length; i++)
{
    // Process the inputs
}

}
That allows you to cycle through without knowing the names of form elements.

Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
Reply With Quote
  #3 (permalink)  
Old Oct 14th, 2007, 09:35
New Member
Join Date: Oct 2007
Location: London
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Simple form submission question

Thanks

That was exactly what I was after, cheers
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
First Hello - and a simple FORM question webhead Introduce Yourself 4 Apr 7th, 2008 18:02
[SOLVED] Simple Question: Why does Font Style change on Web Page in different Browse BlackReef Web Page Design 11 Dec 7th, 2007 09:39
Form Submission page markusdavid Web Page Design 3 Sep 8th, 2007 00:50
Simple form elements question! jtotheb PHP Forum 3 Jul 18th, 2007 14:54
form submission with Javascript ktsirig JavaScript Forum 1 Dec 18th, 2006 21:16


All times are GMT. The time now is 22:39.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43