Option Button Selection

OK. My project also includes the following: I am trying to find a way to set the value of a radio button based on a returned field from sql. I cant get the value of the radio button to change. Whenever the function in the code below is run, it always returns the first $row value. I am looking to have the radio button value changed to whichever row corresponds to it. I.E. If row one WOID value is 1, then when selected, the radio button would set its value to 1, if row 2 WOID value is two, radio is set to 2 when selected, etc…

The goal is to allow the user to select a Work Order, then view that particular Work order (Selected by its ID) on a new page.

My code is:

          echo "<tr><td><input type='radio'  name='ID' id='WID' onclick='change()'></td><td><input type='text' id='WOID' value='" .$row["ID"]. "'></td><td>"  . $row["SCFirstName"].  "</td><td> " .$row["SCLastName"]. "</td><td> " .$row["SCAddress"]. "</td><td>" .$row["SCCity"]. "</td><td>" .$row["SCPhone"]. "</td><td>" .$row["Warranty"]. "</td><td>" .$row["WorkRequested"]. "</td></tr>";
    }
   echo "<script type='text/javascript'>
   function change() {
   var WID = document.getElementById('WOID').value;
  alert ('The value was changed to: ' + WID);
}
</script>";
change(" .$row["ID"]. ")

and receive that value in the change function.

You should really tidy your code up. I would humbly suggest:

//untested
<?php 
    $props=(object)array();
    $props->firstName=$row["SCFirstName"];
    $props->lastName=$row["SCLastName"];
    // ...etc
    ?>
<tr>
    <td>
        <input type='radio' name='ID' onclick='change(" .$row["ID"]. ")'>
    </td>
    <td>
        <input type='text' value='" .$row["ID"]. "'>
    </td>
        <?php foreach($props as $key=>$value) : ?>
            <td>
                <?php echo $value; ?>
            </td>
       <?php endforeach; ?>
</tr>


<!--outside the table loop-->
<script>
    function change(rowID) {
        alert('The value was changed to: ' + rowID);
    }
</script>