473,387 Members | 1,942 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,387 software developers and data experts.

Referencing Radio buttons in php generated script

Hi

Just learning JavaScript and I'm trying to reference radio buttons generated
by php, the relevant lines are:

<td width="9%" align="center" class="bg-tb-td"><input name="editArticle"
type="radio" value=" <?php echo $row_rsArticles['articleID']; ?>" onclick =
"document.form1.deleteArticle.checked='false') "/></td>

<td width="9%" align="center" class="bg-tb-td"><input
name="deleteArticle" type="radio" value=" <?php echo
$row_rsArticles['articleID']; ?>" onclick =
"document.form1.editArticle.checked='false')"/></td>

I am trying to make the buttons mutually exclusive - you can see the onclick
event handlers where I am trying to do this. However I can see that this is
wrong because it doesn't allow unique identification for each radio button.
I want a click on one radio button to automatically uncheck its partner.

Any help greatly appreciated.

Thanks
Ian
Dec 14 '06 #1
2 1316
Ian :) wrote:
Hi

Just learning JavaScript and I'm trying to reference radio buttons generated
by php, the relevant lines are:

<td width="9%" align="center" class="bg-tb-td"><input name="editArticle"
type="radio" value=" <?php echo $row_rsArticles['articleID']; ?>" onclick =
"document.form1.deleteArticle.checked='false') "/></td>

<td width="9%" align="center" class="bg-tb-td"><input
name="deleteArticle" type="radio" value=" <?php echo
$row_rsArticles['articleID']; ?>" onclick =
"document.form1.editArticle.checked='false')"/></td>

I am trying to make the buttons mutually exclusive - you can see the onclick
event handlers where I am trying to do this. However I can see that this is
wrong because it doesn't allow unique identification for each radio button.
I want a click on one radio button to automatically uncheck its partner.

Any help greatly appreciated.
The name of the radio buttons must be exactly the same. Once you do
that they will automatically uncheck the other(s) when you click on one.
You should also remove the onClick event since the browser will handle
this automatically for you.

--
http://www.hunlock.com -- Musings in Javascript, CSS.
$FA
Dec 14 '06 #2
VK

Ian :) wrote:
I am trying to make the buttons mutually exclusive - you can see the onclick
event handlers where I am trying to do this. However I can see that this is
wrong because it doesn't allow unique identification for each radio button.
There is absolutely nothing wrong with it. Just opposite: this is the
way a radio group is intended to work in HTML; you must be mixed IDs
and names requirements. Respectively for your task scripting is not
needed at all, plain HTML will suffice:

<input name="deleteArticle" type="radio" value="yes">
<input name="deleteArticle" type="radio" value="no" checked>

Dec 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
2
by: James P. | last post by:
Help, I need to display radio buttons on a form. The data is from SQL table: each row in each table is displayed as a radio button. I have multiple SQL tables so I understand I need to put...
1
by: kenny8787 | last post by:
Hi, can anyone help here? I have the following code generated from a database, I want to have javascript calculate the costs of the selected items using radio buttons, subtotal the costs and...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.