apply $variable to existing textarea without reload
Posted: Fri Sep 25, 2009 10:37 am
I have a form that has a textarea on it. The user fills in the textarea, then on submit that text is added to a postgressql database. All works great - BUT, if the user hits the 'back' button of the browser I want to check to see if they have already added a memo for that record, and if they have re-display the text that they had entered before submitting the form the first time. This works for the textbox but I can't figure out how to place the value returned into the textarea.
Here is the code that involves the query and replacing the data---
This is the part that I can't seem to get:
I've verified that $desc returns a value.
I feel like I'm close, I no longer get errors, but I don't get anything showing in the textarea either! The other 2 boxes fill up just fine.
Thanks!
Here is the code that involves the query and replacing the data---
Code: Select all
If(empty($firstTime)) {
if (!empty($id)){
//Get all info entered and re-diplay in the correct form box
$querySel1 ="select * from stud_safety ";
$querySel1 .="where id = $id;";
$querySel = $querySel1.$querySel;
$resultsSel = pg_query($db_conn, $querySel);
//if there are results from the query
if (pg_num_rows($resultsSel) >0) {
while ($summary = pg_fetch_array($resultsSel)) {
$desc = stripslashes($summary['behavior_desc']);
echo("<document.forms[0].getElementsById('behaviorDesc').value =\"$desc\">");
$_POST['missingOn'] = stripslashes($summary['missingon']);
$_POST['missingOff'] = stripslashes($summary['missingoff']);
} //end while fetch array
}//end query returned results
} //end id number exisis
} //end if firstTime
Code: Select all
$desc = stripslashes($summary['behavior_desc']);
echo("<document.forms[0].getElementsById('behaviorDesc').value =\"$desc\">");
I feel like I'm close, I no longer get errors, but I don't get anything showing in the textarea either! The other 2 boxes fill up just fine.
Thanks!