# Solved: [object HTMLTextAreaElement]



## JiminSA (Dec 15, 2011)

I am updating a db table with content from a form submitted via Ajax. Within the form are two text areas, the first of which happily gets inserted into the db table field and the second gets supplanted with


> [object HTMLTextAreaElement]




```

```
js

```
<script type="text/javascript">
$(document).ready(function(){
$("#submit_add_video").click(function(){
var title = $("#title_v_a").val();
var video_embed_desc_add = $("#video_embed_desc_add").val();
var event_embed_add = $("#video_embed_code_add").val();
var dataString = 'title='+ title + '&video_embed_desc_add='+ video_embed_desc_add + '&video_embed_code_add='+ video_embed_code_add;
$.ajax({
type: "POST",
url: "video_add_process.php",
data: dataString,
cache: false,
success: function(result){
alert(result);
}
});
return false;
});
});
</script>
```
db insert

```
if (isset($_POST))
	{

		$title = addslashes($_POST['title']);
		$desc = addslashes($_POST['video_embed_desc_add']);
		$embed_code = addslashes($_POST['video_embed_code_add']);
		$date_readable = date("D d M Y");  
		$date_internal = strtotime('today');

		mysql_query("INSERT INTO videos (title, description, embed_code, date_readable, date_internal)

		VALUES ('$title', '$desc', '$embed_code', '$date_readable', '$date_internal')")
		or die(mysql_error());

		echo "Anne, the Video was successfully added! Refresh site to view.";

		exit;
	}	
	else
	{
		echo "Anne, We have a problem with add! Inform Jim ...";
	}
```
I cannot understand how one text area gets into the db alright and the other throws up this anomoly
Any insight would be highly appreciated as I don't have a clue as to what causes this


----------



## Ent (Apr 11, 2009)

```
var [COLOR=Red]event_embed_add[/COLOR] = $("#video_embed_code_add").val(); 
var dataString = 'title='+ title + '&video_embed_desc_add='+ video_embed_desc_add + '&video_embed_code_add='+ [COLOR=Red]video_embed_code_add[/COLOR];
```
Most likely source of anomaly highlighted.

Personally, I'd rather give my variables different names from the objects they get their data from, probably something like video_embed_code_add_val because I'm unimaginative like that, but either way it should work if you're consistent in what name you give.


----------



## JiminSA (Dec 15, 2011)

Thanks Josiah - you definitely put me right, when pointed to the var names have changed the script to

```
<script type="text/javascript">
		$(document).ready(function(){
		$("#submit_add_video").click(function(){
		var title = $("#title_v_a").val();
		var [COLOR="red"]desc[/COLOR] = $("#video_embed_desc_add").val();
		var [COLOR="Red"]embedCode[/COLOR] = $("#video_embed_code_add").val();
		var dataString = 'title='+ title + '&desc='+ desc + '&embedCode='+ embedCode;
		$.ajax({
		type: "POST",
		url: "video_add_process.php",
		data: dataString,
		cache: false,
		success: function(result){
		alert(result);
		}
		});
		return false;
		});
		});
		</script>
<
```
I have marked my error corrections in red. The problem was in the way that I named the vars i.e. with underscores (a php methodology)!


----------

