php - Display dropdown based on checked box -
I have a group of checkboxes 'box' Now I want my dropdown list to show name based on the checkbox database .
Code:
$ sql = "Choose empname from mstEmp where teamtype = '$ d' by command 'empname"; $ ObjDB- & gt; SetQuery ($ SQL); $ Res = $ objDB-> GetQueryReference (); If (! $ Res) exit ("Error in SQL: $ sql"); If $ ($ objDB-> GetNumRows ($ res)>) {while ($ line = mysql_fetch_row ($ res)) {print ("& lt; option value = '{$ row [0]}' & Gt; {line row [0]} & lt; / option & gt; "); }} Mysql_free_result ($ res);
1.select.jsp
& lt ; % @ Page Import = "java.sql. *"% "% & Gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Script type = "text / javascript" & gt; Function Shodeta () {if (document.form.check.checked == true) {xmlHttp = GetXmlHttpObject () var url = "select2.jsp"; XmlHttp.onreadystatechange = stateChanged xmlHttp.open ("GET", url, true) xmlHttp.send (null)}} function stateChanged () {if (xmlHttp.readyState == 4 || xmlHttp.readyState == "full") { Document.getElementById ("name") innerHTML = xmlHttp.responseText. }} GetXmlHttpObject () {var xmlHttp = null; Try {xmlHttp = new XMLHttpRequest (); } Hold (e) {try {xmlHttp = new ActiveXObject ("Msxml2.XMLHTTP"); } Hold (e) {xmlHttp = new ActiveXObject ("Microsoft.XMLHTTP"); }} Return xmlHttp; } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form name = "form" & gt; & Lt; Br> & Lt; Br> & Lt; Input type = "checkbox" id = "check" onclick = "showData ();" & Gt; & Lt; Div id = 'name' & gt; & Lt; B & gt; Select data & lt; / B & gt; & Lt; Select name = 'name' & gt; & Lt; Option value = '- 1' & gt; & Lt; / Options & gt; & Lt; / Select & gt; & Lt; / Div & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;
Comments
Post a Comment