473,395 Members | 1,441 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Radio buttons and If statements

Hi

Please help, how do i write an if statement to check through 4 radio buttons, if none of the 4 buttons are selected than a message box must popup saying incomplete form, please complete the form before submitting, this is my code for the radio buttons

[HTML]
<td> <table border="0" cellpadding="0" cellspacing="0" id="radiotext">
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Excellent"></TD> <TD Valign="center"> Excellent</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Good"></TD> <TD Valign="center"> Good</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Poor"></TD> <TD Valign="center"> Poor</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Bad"></TD> <TD Valign="center"> Bad</TD></TR>
</TABLE>
</TR>
</TABLE>
</b>
<p>




</p>
<b> Q2: Do the technicians provide feedback if problem is not fixed?
</b></div>
<div align="left">
</div>
</TR>
<TR>
<td> <table border="0" cellpadding="0" cellspacing="0" id="radiotext">
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Excellent"></TD> <TD Valign="center"> Excellent</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Good"></TD> <TD Valign="center"> Good</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Poor"></TD> <TD Valign="center"> Poor</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Bad"></TD> <TD Valign="center"> Bad</TD></TR>
</TABLE>
</TR>
</TABLE>
</b>
<p>
[/HTML]

this is a questionnaire and i have to ensure that all questions are filled out before it gets submitted, please assist, much appreciated
Apr 23 '07 #1
7 3064
KevinADC
4,059 Expert 2GB
You use javascript if you want to do it in the browser. Ask in the javascripting forum or a moderator will move this thread for you when they read it. You can also search on google for "javascript form validation"
Apr 23 '07 #2
r035198x
13,262 8TB
Hi

Please help, how do i write an if statement to check through 4 radio buttons, if none of the 4 buttons are selected than a message box must popup saying incomplete form, please complete the form before submitting, this is my code for the radio buttons

<td> <table border="0" cellpadding="0" cellspacing="0" id="radiotext">
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Excellent"></TD> <TD Valign="center"> Excellent</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Good"></TD> <TD Valign="center"> Good</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Poor"></TD> <TD Valign="center"> Poor</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q1: How is the response to any queries you have from the technician’s onsite?" Value="Bad"></TD> <TD Valign="center"> Bad</TD></TR>
</TABLE>
</TR>
</TABLE>
</b>
<p>




</p>
<b> Q2: Do the technicians provide feedback if problem is not fixed?
</b></div>
<div align="left">
</div>
</TR>
<TR>
<td> <table border="0" cellpadding="0" cellspacing="0" id="radiotext">
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Excellent"></TD> <TD Valign="center"> Excellent</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Good"></TD> <TD Valign="center"> Good</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Poor"></TD> <TD Valign="center"> Poor</TD></TR>
<TR><TD> <INPUT Type="radio" Name="Q2: Do the technicians provide feedback if problem is not fixed?" Value="Bad"></TD> <TD Valign="center"> Bad</TD></TR>
</TABLE>
</TR>
</TABLE>
</b>
<p>


this is a questionnaire and i have to ensure that all questions are filled out before it gets submitted, please assist, much appreciated
What have you tried so far? Have you written any Javascript functions before?
Apr 24 '07 #3
Hi

Yes i have tried making a validation function by it doesnt seem to work, i tried running the function Onsubmit as well as creating a button - Onclick,but they both don't run, is there a problem with my coding?
Apr 24 '07 #4
r035198x
13,262 8TB
Hi

Yes i have tried making a validation function by it doesnt seem to work, i tried running the function Onsubmit as well as creating a button - Onclick,but they both don't run, is there a problem with my coding?
and where is this function of yours?
Apr 24 '07 #5
function whichButton() {
If(radio.value==null){
alert("A Question has not been answered")
}
else{
alert("Please click on send")
}

Please bear in mind i am a begginner
Apr 24 '07 #6
r035198x
13,262 8TB
function whichButton() {
If(radio.value==null){
alert("A Question has not been answered")
}
else{
alert("Please click on send")
}

Please bear in mind i am a begginner
You have neither passed nor declared radio in the function whichButton. You need to pass the form that contains the buttons to that function and then retrieve the values from them through that form.
Apr 24 '07 #7
Hi

can you please assist me in doing this, i am not sure how to do that?

Thanks
Apr 24 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: amith | last post by:
hi, i have some 10 radio buttons meant to take the rating from the user. ex: 1 2 3 4 5 6 7 8 9 10 looks O O O O O O O O O O 1 2 3 4 5 6 7 8 9 10 features O O O O O O O O O O
16
by: Stuart | last post by:
I have a page where I utilise the left and right cursor keys to change an image, also on this page is a groups of radio buttons, unfortunately when a radio button is clicked the focus for the...
4
by: Blasting Cap | last post by:
I have a page that has a number of radio buttons that will be displayed to different access levels of a user who logs in to my website. For instance, if there are a dozen buttons, user1 will see...
4
by: Z.K. | last post by:
I started a forms application and I put on the form three buttons. In the functions for the radio buttons I put in a single messagebox like: MessageBox("Hello 1") MessageBox("Hello 2") ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.