drfhazfar Posted April 2, 2009 Share Posted April 2, 2009 I have a php page that I use an AJAX function on the button click. It is suppose to send the text from a textarea to my save_page.php but does not instead it sends [object HTMLTextAreaElement] not the text associated with the object. Very confusing tried different ways but always get the same object. Thanks any help would be great. David Here is the page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script type="text/javascript" src="update_page.js"></script> </head> <body> <? $page_id=$_GET['page_id']; $location_id=$_GET['location_id']; $attribute_id=$_GET['attribute_id']; echo ' Page Text:'; include("dbconnect.php"); try { /*** query the database ***/ $result=mysql_query("select data FROM page_data WHERE page_id = $_GET[page_id] AND location_id = $_GET[location_id] AND attribute_id = $_GET[attribute_id]"); while($row = mysql_fetch_array($result)) { /*** create the textarea ***/ echo '<textarea style=\"width:90%;height:200px\" id=page_data >'; echo $row['data'] ."\n"; echo '</textarea>'; echo '<br><br><br>'; } } catch(PDOException $e) { echo 'No Results'; } $new_data = $_POST['page_data']; ?> <input type="Button" value="Save" name="Save" onclick="saveData(<?=$page_id?>,<?=$location_id?>,<?=$attribute_id?>,page_data);//<?=$new_data?>)"> </body> </html> Quote Link to comment Share on other sites More sharing options...
irvieto Posted April 2, 2009 Share Posted April 2, 2009 Hi. It is a HTML-javascript issue. "page_data" is just the id of the textarea (a html object). page_data.value will give you the text. Try: onclick="saveData(<?=$page_id?>, <?=$location_id?>, <?=$attribute_id?>, page_data.value);" Quote Link to comment Share on other sites More sharing options...
drfhazfar Posted April 2, 2009 Author Share Posted April 2, 2009 Thanks boy I feel silly I tried page_data.Value() never thought to drop the () thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.