Webforumz's RSS FeedRSS Webforumz RegistrationRegister Contact Webforumz StaffContact

[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.


 Subscribe in a reader

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

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Oct 13th, 2007, 16: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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old Oct 13th, 2007, 23: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)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Oct 14th, 2007, 10: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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
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
[SOLVED] Simple Question: Why does Font Style change on Web Page in different Browse BlackReef Web Page Design 11 Dec 7th, 2007 10:39
Form Submission page markusdavid Web Page Design 3 Sep 8th, 2007 01:50
Simple form elements question! jtotheb PHP Forum 3 Jul 18th, 2007 15:54
form submission with Javascript ktsirig JavaScript Forum 1 Dec 18th, 2006 22:16


All times are GMT. The time now is 18:49.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8