Hi everyone,
I need a bit of help with a bit of code I am working on. I have started off by calling the entries in my table and inserting a radio button for each entry, which all works fine. When a radio button is selected it needs to change the value of the text field, "FieldName" to display the entry's ID and NAME. But currently when one is selected, it changes the value of the text field to "NaN" (Not a Number). Could anyone show me where I am going wrong?
<table border="1" bordercolor="#003366" cellspacing="5">
<?php
$conn = mysql_connect("localhost","root","password")
or die(mysql_error());
mysql_select_db("xxx",$conn) or die(mysql_error());
$sql = "SELECT * from table_name";
$result = mysql_query($sql, $conn) or die(mysql_error());
while ($newArray = mysql_fetch_array($result))
{
$number = $newArray['number'];
$id = $newArray['id'];
$name = $newArray['name'];
$thumb_img = $newArray['thumb_img'];
echo "<tr>
<td border=\"1\" bordercolor=\"#003366\" cellspacing=\"5\" bgcolor=\"#ffffff\">
<input type=\"radio\" name=\"designs\" value=\"$id . ' - ' . $name\"
onclick=\"FieldName.value = '$id . ' - ' . $name';\">
$name
<image src=\"http://www.way/to/image/$thumb_img\" width=\"130px\" height=\"130px\">
<br>
</td>
</tr>";
}
?>
<tr>
</tr>
</table>
<table border="1" bordercolor="#003366" cellspacing="5">
<tr>
<td>
<div class="class_name">
You have selected
<input type="text" size="35" value="Please make a selection" name="FieldName" id="FieldName">
</div>
</td>
</tr>
</table>