PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, September 8, 2022

[FIXED] How can I make my radio checkbox's only be allowed one check per row in my table

 September 08, 2022     ajax, php, radio-button     No comments   

Issue

I'm having an issue where I'm using three radio's for three different options in my database. I'm trying to use UserLevel (3, 2 or 1 | 3 means Admin, 2 means Staff and 1 means Member). I made it so that when the specific radio is checked, it updates that users database query. But*, it's making the checkbox vertically in a set ( they're running downwards so only 1 can be selected in each vertical column). I want it so for each users ROW, it allows only one to be checked.

I have a picture of what I mean here :

checkbox's are in a set (vertical) instead of horizontally for each clients row. I want it the other way around.

My code :

<td style="border: 1px solid #eee; text-align: center; font-size: 11px;"  onBlur="saveToDatabase(this,'userLevel','<?php echo $faq[$k]["id"]; ?>')" onClick="showEdit(this);">
<input name="admin" class="admin" type="radio" value="<?php echo $faq[$k]["id"]; ?>" <?php if ($faq[$k]["userLevel"] == 3){?> checked="checked" <?php } ?>>
<input name="staff" class="staff" type="radio" value="<?php echo $faq[$k]["id"]; ?>" <?php if ($faq[$k]["userLevel"] == 2){?> checked="checked" <?php } ?>>
<input name="member" class="member" type="radio" value="<?php echo $faq[$k]["id"]; ?>" <?php if ($faq[$k]["userLevel"] == 1){?> checked="checked" <?php } ?>>


Solution

I. Logic, for radio button, the name should be equal for all choices. So, does not use 'admin/staff/member' names, but something like name="rights[<?php echo $faq[$k]["id"]; ?>" Thanks to Georges O.

I needed to create different names for each radio checkbox. Now it works like a charm.



Answered By - BenZa Music
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing