Auto - Check a radio button when a link is Clicked

Discussion in 'PHP' started by greatthings, Nov 28, 2011.

  1. #1
    hmmmmmm help???
    How could i Auto - Check a radio button when a link is Clicked?

    if the update link (<a href="update.php">update</a>) is clicked,
    its corresponding radio button must be clicked/checked also, how can i do that ?

    :( can someone help me?? :(

    if not, what is the best way to get and update values from database??
     
    greatthings, Nov 28, 2011 IP
  2. 7thand43rd

    7thand43rd Member

    Messages:
    84
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #2
    You need to check into Javascript / AJAX (To access the database). jQuery is a library that will get you started and is easy to comprehend.
     
    7thand43rd, Nov 28, 2011 IP
  3. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #3
    // set the radio button with the given value as being checked
    // do nothing if there are no radio buttons
    // if the given value does not exist, all the radio buttons
    // are reset to unchecked
    function setCheckedValue(radioObj, newValue) {
    	if(!radioObj)
    		return;
    	var radioLength = radioObj.length;
    	if(radioLength == undefined) {
    		radioObj.checked = (radioObj.value == newValue.toString());
    		return;
    	}
    	for(var i = 0; i < radioLength; i++) {
    		radioObj[i].checked = false;
    		if(radioObj[i].value == newValue.toString()) {
    			radioObj[i].checked = true;
    		}
    	}
    }
    HTML:
    Source and examples here: http://www.somacon.com/p143.php
     
    mfscripts, Nov 30, 2011 IP