how 'bout trying this instead:
$sql="SELECT * FROM contacts";
$res=mysql_query($sql,$con) or die("SQL: $sql"

;
While ($row=mysql_fetch_array($res)) {
$pr_name_first=$row['pr_name_first'];
//
print "<input type=\"text\"";
print " name=\"contact_details[pr_name_first]\"";
print " value=\"$pr_name_first\">";
//
// whatever else u want
//
}
I've done it like this to create a module that creates an online "programmable" questionaire and all the form fields you add for each question are referenced as arrays like:
<input type="text" name="Q[1]" value="$Q[1]">
and when submitted, the php script pulls them out as array
values like this:
foreach ($Q as $value) {
$sql="INSERT INTO $table (id,value) VALUES (NULL,'$value')";
mysql_query($sql,$con) or die("Unable to save $value"

;
}
as for referencing them in javascript BEFORE the form is submitted, you can access them just as said above:
document.myform.contact_details['pr_name_first'].value
or
document.myform.contact_details['pr_name_first'].src
(if you wanna change what it is holding for something else)
hope it helps.
I've got lots of working examples if u wanna look.
just lemme know