Question : jquery plug in

BACKGROUND

The below code represents how I access data from a proprietary ERP system into custom web forms.
My goals are:
1. Significantly reduce the code thru re-use of repetitive element.
2. Make development of web forms using this functionality (in the code sample) much easier, perhaps even drag and drop of data elements to create custom forms.

The bwebrqb.dll accepts the reportfetch method information and returns an xml document with data embedded in xml attributes.  I then render html and place it into a div tag.  

EXPERTS QUESTIONS:
1. Is this sort of code a good candidate for a plug in to help reduce the amount of code in the web form java script
2.  Any structural recommendations to set me on the right course?
3.  What issues might you foresee that I will run into?
4.  Is there a better way to approach reducing the code?

My experience levels are as follows
1.  Javascript:  intermediate
2. Jquery:  Beginning, but learning fast
3. JQuery plug ins:  beginning to research
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
function paintSXML(SXML, BObject,BSearch)
{

var nodes = SXML.selectNodes("//ColumnInfo/*")

//adding in data retrieval of requested record;  will remove separate function after this is completed.

var Requestor = document.getElementById("Requestor").value;
var Connection = document.getElementById("Connection").value;
var arrstring = document.getElementById("commandbox").value.split(" ")
var searchstring = arrstring[1]

var reportFetch = new ReportFetch(Requestor, Connection); //standard
reportFetch.SetRelativePath("../../isapi/bwebrqb.dll"); //standard
reportFetch.SetApplySecurity(true);
var DataObject = reportFetch.AddDataObject(BObject);
reportFetch.AddProperty(BObject,BSearch)
for(y=0;y<nodes.length;y++)
{
	reportFetch.AddProperty(BObject,nodes[y].nodeName);		
}
	var DataWhere = DataObject.GetWhereClause();	
	DataWhere.AddParam(BSearch, searchstring , "eq");
	var reportfetchXML = reportFetch.GetRecords();	
	if (reportfetchXML) 
	{          
		var responseNode = reportfetchXML.selectSingleNode("//Response/Detail");
	}




var html = "<table>"

for(x=0;x<nodes.length;x++)
{
var colval=""
var colval = responseNode.getAttribute(nodes[x].nodeName) 

html += "<tr>"
html += "<td>" + nodes[x].getAttribute("Tag")  + "</td><td><input value='"  + colval +  "' type='text' id='general_" + nodes[x].nodeName + "_1' \
name='general_" + nodes[x].nodeName + "_1' size='" + nodes[x].getAttribute("MaxLen") + "' title='" + nodes[x].nodeName + "' /></td>\
</tr>";
}
html += "</table>";



$('#divregion').html(html)
}

Answer : jquery plug in

I won't comment on the first part of the code, as it uses a library that I'm not familiar with.

Here's how I would have done the second half:
1:
2:
3:
4:
5:
6:
7:
8:
9:
var html = "<table>";
for(x=0; x<nodes.length; x++) {
	colval = responseNode.getAttribute(nodes[x].nodeName);
	html += "<tr><td>" + nodes[x].getAttribute("Tag") + "</td>"+
		"<td><input value='" + colval + "' type='text' id='general_" + nodes[x].nodeName + "_1'"+
		"name='general_" + nodes[x].nodeName + "_1' size='" + nodes[x].getAttribute("MaxLen") + "'"+
		"title='" + nodes[x].nodeName + "' /></td></tr>";
}
$('#divregion').html(html + "</table>");
Random Solutions  
 
programming4us programming4us