How do i submit a form with radio buttons ?

This is a discussion on "How do i submit a form with radio buttons ?" within the Web Page Design section. This forum, and the thread "How do i submit a form with radio buttons ? are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 12th, 2007, 13:44
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
How do i submit a form with radio buttons ?

I have a form that is basicaally just 10 radio buttons, to allow people to rate other members on my dating site.

At the moment i have a submit button... but id like the form to automatically submit when a user chooses a radio button, instead of having to click the submit bnutton.

Anyone know how i would go about this?

Thanks for any help chaps
Reply With Quote

  #2 (permalink)  
Old May 12th, 2007, 16:57
New Member
Join Date: May 2007
Location: Sendai, Japan
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How do i submit a form with radio buttons ?

Maybe something like this: http://bonrouge.com/demos/auto_submit.htm

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>auto_submit</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
window.onload=function() {
var rbuttons=document.theForm.rate;
    for (i=0; i<rbuttons.length; i++) {
        rbuttons[i].onclick=function() {document.theForm.submit();}
    }
}
</script>
</head>
<body>
<form action="formhandler.php" name="theForm" method="post">
<fieldset>
<legend>Rate</legend>
<label>1<input type="radio" name="rate" value="1"></label>
<label>2<input type="radio" name="rate" value="2"></label>
<label>3<input type="radio" name="rate" value="3"></label>
<label>4<input type="radio" name="rate" value="4"></label>
<label>5<input type="radio" name="rate" value="5"></label>
<input type="submit" value="submit">
</fieldset>
</form>
</body>
</html>

Last edited by BonRouge; May 12th, 2007 at 17:34.
Reply With Quote
  #3 (permalink)  
Old May 12th, 2007, 18:13
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How do i submit a form with radio buttons ?

eeek ... you mean i have to use javascript ?.... that goes against my moral fibre ... is there an other way?... maybe using php?
Reply With Quote
  #4 (permalink)  
Old May 12th, 2007, 18:17
New Member
Join Date: May 2007
Location: Sendai, Japan
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How do i submit a form with radio buttons ?

Er... no, I don't think so.
Reply With Quote
  #5 (permalink)  
Old May 12th, 2007, 18:21
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How do i submit a form with radio buttons ?

ok, thanks mate ... ill do some research and probably use some javascript in the end ... cheers
Reply With Quote
  #6 (permalink)  
Old May 12th, 2007, 18:34
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How do i submit a form with radio buttons ?

Yeah, javascript is pretty much the best way to do this. I have done something similar in PHP but there were all kinds of complications I haven't yet straightened out.

If you wanted to use a server-side script, my suggestion would be to get "outside the box". I'd use a submit button rather than a radio button. Just display a separate POST form, with a submit button and a hidden field, for each choice. Use the button to display the choice and the hidden input to hold it (since the submit button has to hold the submit variable, AFAIK). The form handling would take some creative work, primarily to allow only one vote, but it shouldn't be all that difficult.

I did try something like this once -- the form handler accessed records from a mysql database and displayed them -- and it worked fine, but I had to abandon it because I wanted my form to allow for multiple variables, ie checkboxes.

Last edited by masonbarge; May 12th, 2007 at 18:36.
Reply With Quote
Reply

Tags
form

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] Help with Radio buttons Oak JavaScript Forum 17 Feb 2nd, 2008 09:44
Radio Buttons and Javascript activeware JavaScript Forum 6 Dec 11th, 2007 18:02
[SOLVED] large radio button form submit chriscant JavaScript Forum 7 Oct 25th, 2007 09:03
Radio buttons and mandatory fields joshcxa JavaScript Forum 1 Aug 8th, 2006 10:30
Radio Buttons redhead Web Page Design 2 Apr 12th, 2004 19:00


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


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