Code:
Function getqlist (ID)
{
VaR url = "ajaxmethod/qlist_ajax.ashx? Id = "+ ID +" & Ver = "+ new date (). gettime ();
// Jquery. Get (URL, showxml );
Jquery. Ajax ({
Type: "Get ",
URL: URL,
// Data: "id =" + ID + "& Ver =" + new date (). gettime (),
Success: showxml,
Datatype: "text/XML"
});
}
Function showxml (data ){
VaR Container = jquery ("# dragcontainer1 ");
VaR qlistobj = jquery (data );
VaR html = "";
VaR qlistid = qlistobj. Children ("ID"). Text ();
VaR qlistname = qlistobj. Children ("name"). Text ();
VaR qlistinfo = qlistobj. Children ("info"). Text ();
If (qlistname! = ""){
HTML + = "<Table width = '000000' style = 'font-size: 13px; 'border = '0' cellspacing = '3' cellpadding = '0'> ";
HTML + = "<tr> ";
HTML + = "<TD width = '000000' style = 'font-size: 15px; '> <B>" + qlistname + "</B> </TD> ";
HTML + = "<TD width = '000000' style = 'font-size: 14px; '> & nbsp; </TD> ";
HTML + = "</tr> ";
HTML + = "<tr> ";
HTML + = "<TD> additional information:" + qlistinfo + "</TD> ";
HTML + = "</tr> ";
HTML + = "<tr> <TD> </TD> <TD> & nbsp; </TD> </tr>"
HTML + = "</table> ";
Jquery ("# divqlist" ).html (HTML );
Html = "";
}
VaR questionarray = qlistobj. Find ("Question ");
Jquery ("# questioncount") [0]. value = questionarray. length;
Questionarray. Each (function (I, item ){
VaR question = jquery (item );
VaR qid = question. Children ("ID"). Text ();
VaR qcontent = question. Children ("content"). Text ();
VaR qtype = question. Children ("type"). Text ();
VaR qmax_answer_length = question. Children ("max_answer_length"). Text ();
VaR qpreindex = question. Children ("preindex"). Text ();
VaR qoptions = question. Children ("options"). Find ("option ");
VaR qtag = "<span id = 'qtag _" + qid + "'>" + eval (I + 1) + "</span> ";
VaR qordertype = question. Children ("ordertype"). Text ();
VaR qis_mandatory = question. Children ("is_mandatory"). Text ();
If (qis_mandatory = "1 ")
{
Qcontent + = "& nbsp; <span id =/" need _ "+ qid +"/"class =/" need/"> * </span> ";
}
Else
{
Qcontent + = "& nbsp; <span id =/" need _ "+ qid +"/"class =/" need/"> </span> ";
}
HTML + = "<Div class = 'dragbox' id =/" Div _ "+ qid +"/"> ";
HTML + = "<Table width = '000000' border = '0' cellspacing = '0' cellpadding = '0' align = 'right' class = 'center'> ";
HTML + = "<tr> ";
HTML + = "<TD width = '000000' style = 'padding-left: 10px; '>" + qtag + "." + qcontent + "</TD> ";
HTML + = "<TD width = '5% 'align = 'right'> <a href = 'javascript: Edit (/" "+ qid + "/", /"" + qtype + "/"); '> ";
HTML + = " </a> </TD> ";
HTML + = "<TD width = '5% 'align = 'right'> <input type =/" checkbox/"name =/" chkid/"value =/" "+ qid + "/"/> & nbsp; </TD> ";
HTML + = "</tr> ";
If (qtype = "0 ")
{
HTML + = "<tr> ";
HTML + = "<TD style = 'padding-left: 10px; '>" + showoption (0, qmax_answer_length ,"","","") + "</TD> ";
HTML + = "</tr> ";
}
Else
{
HTML + = "<tr> ";
VaR qhtml = "";
VaR rowcount = parseint (qordertype );
VaR optioncount = qoptions. length;
VaR widthinfo;
If (parseint (optioncount) <parseint (qordertype ))
{
Rowcount = parseint (optioncount );
}
If (qordertype! = "0 ")
{
Widthinfo = "width = '" + eval (100/rowcount) + "% '";
}
Qhtml + = "<Table width =/" 100%/"border =/" 0/"cellspacing =/" 0/"cellpadding =/" 0/"> ";
Qhtml + = "<tr> ";
Qoptions. Each (function (J, T ){
VaR optionitem = jquery (t );
VaR OID = optionitem. Find ("ID"). Text ();
VaR oname = optionitem. Find ("name"). Text ();
VaR ovalue = optionitem. Find ("value"). Text ();
VaR otag = "<label id = 'tag _" + OID + "'For =/" rb "+ OID +"/">" + gettag (J + 1) + "</label> ";
VaR orel_id = optionitem. Find ("rel_id"). Text ();
VaR oindex_num = optionitem. Find ("index_num"). Text ();
Qhtml + = "<TD" + widthinfo + "style = 'padding-left: 10px; '>" + showoption (qtype, qmax_answer_length, oname, ovalue, otag, OID );
Qhtml + = "</TD> ";
If (qordertype = "0 ")
{
Qhtml + = "</tr> <tr> ";
}
Else if (J + 1) % rowcount = 0)
{
Qhtml + = "</tr> <tr> ";
}
});
Qhtml + = "</tr> ";
Qhtml + = "</table> ";
HTML + = "<TD>" + qhtml + "</TD> ";
HTML + = "<TD> & nbsp; </TD> ";
HTML + = "</tr> ";
}
HTML + = "</table> ";
HTML + = "</div> ";
If (I = 0)
{
Jquery ("# questionlist") [0]. value = qid;
Jquery ("# questionis_mandatory") [0]. value = qis_mandatory;
Jquery ("# questionordertype") [0]. value = qordertype;
// Initialize the arrangement
Updateordertype (qpreindex );
}
Else
{
Jquery ("# questionlist") [0]. value = jquery ("# questionlist") [0]. Value + "," + qid;
Jquery ("# questionis_mandatory") [0]. value = jquery ("# questionis_mandatory") [0]. Value + "," + qis_mandatory;
Jquery ("# questionordertype") [0]. value = jquery ("# questionordertype") [0]. Value + "," + qordertype;
}
});
Container.html (HTML );
}
The XML structure is as follows:
<Qlist xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: XSD = "http://www.w3.org/2001/XMLSchema" xmlns = "http://www.Trusit.com/hd_Feedback">
<ID> 49e1b65e-710d-440c-8f9f-293889a52a68 </ID>
<Name> HP commercial project satisfaction survey </Name>
<Info> HP commercial project satisfaction return visit questionnaire </INFO>
<Project> 34ed9414-a2cc-456d-a3d7-dc92d203c438 </Project>
<Available> 1 </available>
<Questions>
<Question>
E1325D9B-1F4F-4832-845D-50EACBE3C666
<Content> Are you satisfied with the overall service attitude of field engineers? (Service attitude) </content>
<Type> 1 </type>
<Standard_answer/>
<Project> c7305350-7b66-47ed-9d74-b65befc3e16b </Project>
<Max_answer_length> 0 </max_answer_length>
<Available> 1 </available>
<Rel_id> 5d185a63-1eeb-4478-8457-17cf6ebec69e </rel_id>
<Is_mandatory> 1 </is_mandatory>
<Ordertype> 5 </ordertype>
<Preindex> 0 </preindex>
<Options>
<Option>
<ID> 3a9b0d81-5990-4b7d-aae3-19ed3633607f </ID>
<Name> very satisfied </Name>
<Value> 5 </value>
<Project> c7305350-7b66-47ed-9d74-b65befc3e16b </Project>
<Available> 1 </available>
<Index_num> 1 </index_num>
<Rel_id> F21373DA-3558-4026-9D78-2C94F3717C1B </rel_id>
</Option>
<Option>
F06CF226-83B1-40A0-AA00-52DF9C7E7AB0
<Name> satisfied </Name>
<Value> 4 </value>
<Project> c7305350-7b66-47ed-9d74-b65befc3e16b </Project>
<Available> 1 </available>
<Index_num> 2 </index_num>
<Rel_id> 615db316-92ae-409d-9ded-f7cf08277738 </rel_id>
</Option>
<Option>
AA9CCE1C-8FEC-4386-9F13-8FB42422C113
<Name> General </Name>
<Value> 3 </value>
<Project> c7305350-7b66-47ed-9d74-b65befc3e16b </Project>
<Available> 1 </available>
<Index_num> 3 </index_num>
<Rel_id> 2b4ffa59-911b-411f-8272-51337318afe6 </rel_id>
</Option>
<Option>
...
Why is it normal for me to read the XML data at the first layer? When I read the data in the option, I cannot get the data. What I get is control. Why? There is a problem with the red font. Could you give me some advice?