change value of a php variable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    change value of a php variable

    Code:
    for ($i = 1 ; $i < $count; $i++){
    for($k = 1; $k <= 10; $k++){
    if($tocheck == $k){
    $chk = "checked";
    }
    else
    {
    $chk = "";
    }
    
    $myresult .= "<input class='star' type='radio' name='rating".$i."' id='rating".$i."".$k."' value='". $k ."' $disabled  $chk  title='". $k." out of 10 '/>&nbsp;&nbsp;";
    
    }
    $myresult .= "</span>";
    $myresult .= "<input type=\"button\" value=\"Rate It\" onclick=\"javascript: $('.hide".$i."').show('show');\" >";
    }

    when i click on the Rate it button. the value of all the radiobuttons should become 0 . i.e the $chk must become NULL . how can i achieve this using javascript/ajax/jquery method ?
  • pradeepjain
    Contributor
    • Jul 2007
    • 563

    #2
    i could solve this by using jquery ! thanks for the help!

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      If you're thinking of changing the PHP variable, the approach is incorrect. The page has loaded, so JavaScript on the client doesn't have access to PHP variables. Either you can make an Ajax request to a PHP script which reproduces the default radio buttons which you can use to replace the ones on the page, or the better method would be to just loop over the radio buttons on the page and change their values using JavaScript.

      Comment

      Working...