Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
multiple radios validation
Old 12-30-2008, 08:41 AM multiple radios validation
Skilled Talker

Posts: 97
Trades: 0
hi everyone plz i want to make a validation function for the radio buttom that have an id myradiobutton[i]
and i varries from 1 to 8

but i cant till now make the validation
can anyone help me plz or send for me the function???



<form action="test.php" method="post" name="radio_form" id="radio_form" onsubmit="return radio_button_checker()">
<tr class="bg_1">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton1" id="myradiobutton1" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton1" id="myradiobutton1" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton1" id="myradiobutton1" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton1" id="myradiobutton1" /></td>
</tr>
<tr class="bg_2">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton2" id="myradiobutton2" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton2" id="myradiobutton2" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton2" id="myradiobutton2" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton2" id="myradiobutton2" /></td>
</tr>
<tr class="bg_1">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton3" id="myradiobutton3" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton3" id="myradiobutton3" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton3" id="myradiobutton3" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton3" id="myradiobutton3" /></td>
</tr>
<tr class="bg_2">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton4" id="myradiobutton4" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton4" id="myradiobutton4" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton4" id="myradiobutton4" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton4" id="myradiobutton4" /></td>
</tr>
<tr class="bg_1">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton5" id="myradiobutton5" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton5" id="myradiobutton5" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton5" id="myradiobutton5" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton5" id="myradiobutton5" /></td>
</tr>
<tr class="bg_2">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton6" id="myradiobutton6" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton6" id="myradiobutton6" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton6" id="myradiobutton6" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton" id="myradiobutton6" /></td>
</tr>
<tr class="bg_1">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton7" id="myradiobutton7" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton7" id="myradiobutton7" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton7" id="myradiobutton7" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton7" id="myradiobutton7" /></td>
</tr>
<tr class="bg_2">
<td align="center" valign="top"><input type="radio" value="1" name="myradiobutton8" id="myradiobutton8" /></td>
<td align="center" valign="top"><input type="radio" value="2" name="myradiobutton8" id="myradiobutton8" /></td>
<td align="center" valign="top"><input type="radio" value="3" name="myradiobutton8" id="myradiobutton8" /></td>
<td align="center" valign="top"><input type="radio" value="4" name="myradiobutton8" id="myradiobutton8" /></td>
</tr>

</form>
</table>
</body>
</html>
john_zakaria is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-30-2008, 12:30 PM Re: multiple radios validation
pealo86's Avatar
Super Spam Talker

Posts: 850
Name: Matt Pealing
Location: England, north west
Trades: 0
errrmmm when you say you want it validating, what is it that you are checking for in the form? I'm guessing "myradiobutton[i]" means that you're using a for loop?
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 12-30-2008, 01:18 PM Re: multiple radios validation
wayfarer07's Avatar
Poo on You

Latest Blog Post:
Introducing WowWindow
Posts: 3,985
Name: Abel Mohler
Location: Asheville, North Carolina USA
Trades: 0
Cross forum spammer
__________________
Join me on
Please login or register to view this content. Registration is FREE
wayfarer07 is offline
Reply With Quote
View Public Profile Visit wayfarer07's homepage!
 
Old 12-31-2008, 02:22 AM Re: multiple radios validation
Skilled Talker

Posts: 97
Trades: 0
thnx for everyone , i need to make it using a function
this is my code:

<script language="JavaScript">
<!--
function radio_button_checker()
{
var i=1;
for(i=1;1<9;i++) // i have 8 radio buttons
{
// set var radio_choice to false
var radio_choice = false;

// Loop from zero to the one minus the number of radio button selections
for (counter = 0; counter < radio_form.myradiobutton[i].length; counter++)
{
// If a radio button has been selected it will return true
// (If not it will return false)
if (radio_form.radmyradiobutton[i][counter].checked)
radio_choice = true;
}

if (!radio_choice)
{
// If there were no selections made display an alert box
alert("Please select a letter.")
return (false);
}
return (true);
}


}
</script>


the red scirpt is working correctly
but when i made the for loop to start from myradiobutton1 to myradiobutton8
it did not work correctly
john_zakaria is offline
Reply With Quote
View Public Profile
 
Old 12-31-2008, 07:05 AM Re: multiple radios validation
pealo86's Avatar
Super Spam Talker

Posts: 850
Name: Matt Pealing
Location: England, north west
Trades: 0
I think it might work if you remove '.length' from your radio button variable in the for loop.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
pealo86 is online now
Reply With Quote
View Public Profile Visit pealo86's homepage!
 
Old 12-31-2008, 02:05 PM Re: multiple radios validation
Skilled Talker

Posts: 70
Location: Atlanta, GA
Trades: 0
Why are you using the same id for multiple radio buttons? This isn't proper coding.
LayneMitch is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to multiple radios validation
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.48492 seconds with 12 queries