kaht, here is the problem i am having, I will try to explain and show all code. I have a page where I use HS and AJAX calls. AJAX makes a call to RetirementIncome.aspx page thtt gets a bunch of newsletters for a given zipcode. I am dynamically creating checkboxes based on that. You will see "newsletter" in the code. Newsletter variable has the value of the table element to which I am appending dynamic checkboxes. Now there is a validator that is looking at the element that newsletter hold id for.
All checkboxes are showing fine but after I submit to server validator complains. I guess somehow when checkbox is checked I need to retain that value and then whe I am populating checkboxes after potback, show that. How to do that? Here is the complete code
<%--FOR MEMO FIELD TO SPAN ALL COLUMNS, USE CODE BELOW--%>
<tr>
<td colspan="3">
<b></b>
<script>
var http_request = false;
function makePOSTRequest(url, parameters, callback) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
//alert('Cannot create XMLHTTP instance');
return false;
}
http_request.onreadystatechange = callback;
http_request.open('POST', url, true);
http_request.setRequestHeader("Content-type", "application/x-
http_request.setRequestHeader("Content-length", parameters.length);
http_request.setRequestHeader("Connection", "close");
http_request.send(parameters);
}
function callback()
{
if (http_request.readyState == 4)
{
if (http_request.status == 200)
{
result = http_request.responseText;
eval(result);
}
}
}
function makeCheckboxes(str) {
var a = document.getElementById(newsletters);
var oRow; var oCell; oRow = a.insertRow(); oCell = oRow.insertCell();
var arr = str.split(",");
var returnStr = "";
for (i = 0; i < arr.length; i++) {
var arr2 = arr
.split("?");
var id = newsletters + "_" + i;
alert (id);
returnStr +="<input type='checkbox' onclick='RetainValue(this)' id='" + id + "' name=' " + arr2[1] + "' value='" + arr2[1] + "'/>" + arr2[0] + "<br>";
}
oCell.innerHTML = returnStr;
}
function RetainValue(obj)
{
???? what
}
function getCheckboxes()
{
makePOSTRequest("RetirementIncome.aspx?cb=makeCheckboxes&zip=" + escape(document.getElementById(zipcode).value) , "", callback);
}
getCheckboxes();
alert(newsletters.value);
</script>
</td>
</tr>