Jump to content

[SOLVED] textarea will not POST passes [object HTMLTextAreaElement]


drfhazfar

Recommended Posts

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>

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);"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.