I have a VS2010,C# ASP.NET web app, I've written a JavaScript (in aspx page) that works perfect in firefox but almost does nothing in chrome or IE, it is my function:
<script type="text/javascript" >
function onRadioChange(rowIndex, value, myHref) {
var q = document.getElementById('HF').value.toString();
var q2 = q.split(',');
var new_HF = '';
for (var i = 0; i < rowIndex; i++) {
new_HF += q2[i] + ',';
}
new_HF += value.toString() + ',';
for (var j = rowIndex; j < q2.length - 1; j++) {
if (j > rowIndex) {
new_HF += q2[j] + ',';
}
}
document.getElementById('HF').value = new_HF;
//user has voted all questions? enable hpAccept so that he can go to next questionnaire
var q5 = new_HF.split(',');
var all_ok = true;
for (var g = 0; g < q5.length; g++) {
if (q5[g] == '0')
all_ok = false;
}
if (all_ok) {
document.getElementById('hpAccept').disabled = false;
document.getElementById('hpAccept').href = myHref;
}
}
it seems that this function does nothing in IE or chrome, I placed and alert to display some info but nothing was displayed in chrome or IE, what is wrong with them?
another problem is on the last parts, the hyperlink is initially disabled, but it is enabled in firefox no luck in IE or chrome, what is the problem here? how can I make this function cross-browser?
[EDIT] I put an alert('1') exactly after function definition line and I saw nothing in chrome and IE, it seems that this function is not called in these browsers, I use r.Attributes.Add("onChange", "return onRadioChange('" + (i - 1).ToString() + "','1','" + myHref + "');"); for calling this function in codebehind, r is a dynamically created radiobutton.