The obtained checkbox value does not know where it comes from /? Solution

Source: Internet
Author: User
The obtained checkbox value does not know where it comes from /? I obtained the result from the database and used the roomname field as the value of the checkbox. how can I add the result to the data obtained in the summitdata function of the javascript script and mcustom. php /? The obtained checkbox value does not know where it comes from /?
I obtained the result from the database and used the roomname field as the value of the checkbox. how can I add the result to the data obtained in the summitdata function of the javascript script and mcustom. php /?
1.
Echo "";
2. javascript section
Function checkchecked (checkboxs)
{

For (var I = 0; I {
If (checkboxs [I]. checked)
{
Alert (checkboxs [I]. value); // The value of checkboxs [I]. value obtained here is 101/, which has been added/
Return true;
}

}
Alert ("Please select the room .");
Return false;
}
Function submitdata ()
{
Var checkboxs = document. getElementsByName ("selectrooms []");
Var checked = checkchecked (checkboxs );
If (checked)
{
Var form = document. getElementById ("roomlist ");
Form. submit ();
}
Else
{
Return false;
}
}
3. obtained in mcustom. php
If (isset ($ _ GET ["selectrooms"])
{
$ Selectrooms = $ _ GET ["selectrooms"];
Foreach ($ selectrooms as $ item)
{
Echo"";
Echo"". $ Item .""; // Here also has/
Echo"";
}
}

------ Solution --------------------
Value = ". $ row ['roomname']."/>"; The result is probably value = roomnamevalue/>
There is no space between value and/>, so the browser considers value = roomnamevalue /. We recommend that you add "" to any attribute to include the attribute value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.