# Checkbox

**URL:** <https://forum.kirupa.com/t/checkbox/115030>\
**Category:** Uncategorized\
**Created:** [July 4, 2004, 9:32pm UTC](https://forum.kirupa.com/t/checkbox/115030 "2004-07-04T21:32:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unanet](https://avatars.discourse-cdn.com/v4/letter/u/ccd318/32.png) [@unanet](https://forum.kirupa.com/u/unanet)\
**Post date:** [July 4, 2004, 9:32pm UTC](https://forum.kirupa.com/t/checkbox/115030/1 "2004-07-04T21:32:04Z")

</div>

when i click on a submit button, it sends values to php. i have made 3 checkmoxes. when i select one and then click on a button, i want that the button transfer values that i selected. here is the code.

submit.onPress = function() {

if (checkbox1.value = true) {a1 != “”; a2 != “”; a1value != “”; a2value != “”;

```
  myData.a1value = a1value;
  myData.a2value = a2value;
  myData.sendAndLoad("savebar2.php", myData, "POST");

```

}

if (checkbox2.value = true) {a1 != “”; a2 != “”; a1value != “”; a2value != “”;  
myData.a1 = a1;  
myData.a2 = a2;  
myData.SendAndLoad(“savebar2.php”, myData, “POST”);  
}  
checkbox1 = checkbox1.value;  
checkbox2 = checkbox2.value;  
checkbox3 = checkbox3.value;

myData = new LoadVars();  
myData.onLoad = function() {  
if (this.writing == “ok”) {  
status.text = “Datas are in the text”;  
} else {  
status.text = “error”;  
}}  
};

UN@  
[size=1][/size][size=1][/size]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 5, 2004, 1:38pm UTC](https://forum.kirupa.com/t/checkbox/115030/2 "2004-07-05T13:38:51Z")

</div>

You got a few of errors in your code.  
Whenever comparing variables, use the **==** operator instead of the assignment operator ( **=** );  
You are defining the _myData.a1_ and _myData.a2_ properties even before first declaring the _myData_ object, therefore they will have no value at all.  
Also, i believe you’re using sendAndLoad because you need to get a response from the PHP script. I don’t know if it’s necessary but i usually create another LoadVars object to receive that response. Something like this:

```auto
submit.onPress = function() {
	myData = new LoadVars();
	response = new LoadVars();
	response.onLoad = function() {
		if (this.writing == "ok") {
			status.text = "Datas are in the text";
		} else {
			status.text = "error";
		}
	};
	if (checkbox1.value == true) {
		myData.a1value = a1value;
		myData.a2value = a2value;
		myData.sendAndLoad("savebar2.php", response, "POST");
	}
};

```
