I have a SQL server database table called "log" which stores all my main records. This table has "CallID" and "Priority" fields.
I have a lookup table called "priorities" which has "Priority" and "ResponseResolution" fields.
What I'm trying to do is let a user choose a priority from the lookup list (I'm using PHP) and on doing so, this will display the corresponding ResponseResolution underneath it.
The code below works perfectly on my "addrecord" form because the record is new. My problem is on my "editrecord" form; here I'm selecting a record from the "log" table and want to show both the Priority (as stored on the "log" table for this record) and it's corresponding "ResponseResolution". I presume there will be an onLoad event in the BODY tag. The value of the "Priority" field needs to be combined with all the rest of the possible values.
Can someone please help me? Many thanks in advance
$con = mssql_connect ($hostname, $username, $password);
mssql_select_db ($database, $con);
$linkcallid = $_GET['CallID']; //get call id from URL
$query = "SELECT * from log WHERE CallID = $linkcallid";
var selVal = theId.value;
document.getElementById('ResponseResolution').innerHTML = theId.options[theId.options.selectedIndex].getAttribute("vResponseResolution");
<form method="POST" action="helpdeskaddnewcall.php" name="addrecord"><p>
<SELECT ID="Priority" NAME="Priority" onchange="ShowResponseTimes(this)">
$query="SELECT Priority,ResponseResolution FROM priorities ORDER BY Priority ASC";
$result = mssql_query($query) or die("Query failed : " . mssql_error());
while ($row = mssql_fetch_array($result))
<option value="<?=$row["Priority"]?>" vResponseResolution="<?=$row["ResponseResolution"]?>"> <?=$row["Priority"]?></option>