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>

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.