Dietmar Meier wrote:
ef*****@epitome.com.sg wrote:
In addition to the two other answers, I would replace
[...]
var sReturn="";
for (var i=0;i<oCheckboxs.length;i++){
if (oCheckboxs[i].checked)
if (sReturn=="")
sReturn=oCheckboxs[i].value;
else
sReturn=sReturn+","+oCheckboxs[i].value;
}
[...]
window.location=[...] +sReturn
with
var aReturn = [];
for (var i=0; i<oCheckboxs.length; i++) {
if (oCheckboxs[i].checked) {
aReturn[aReturn.length] = oCheckboxs[i].value;
}
}
[...]
window.location = [...] + aReturn.join(",");
ciao, dhgm
In addition to the three other answers... &:~D
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript">
function processOutcome(els)
{
var TIDs = els.TeamID, id, vals = [];
if ('undefined' == typeof TIDs[0])
TIDs = [TIDs];
for (var i = 0, l = TIDs.length; i < l; ++i)
{
id = TIDs[i];
if (id.checked)
vals.push(id.value);
}
if (!vals.length)
{
alert('\nPlease select a team for Outcome Assessment.');
TIDs[0].focus();
}
else top.location =
'/' +
els.AssessDatabase.value +
'/outcome?openform&TeamID=' +
vals.join(',');
}
</script>
</head>
<body>
<form>
<input type="hidden" name="AssessDatabase" value="somedB">
<br><br>
<input type="checkbox" id="TID1" name="TeamID" value="ID1">
<label for="TID1">ID1</label>
<br>
<input type="checkbox" id="TID2" name="TeamID" value="ID2">
<label for="TID2">ID2</label>
<br>
<input type="checkbox" id="TID3" name="TeamID" value="ID3">
<label for="TID3">ID3</label>
<br><br>
<input
type="button"
value="process"
onclick="return processOutcome(this.form.elements)">
</form>
</body>
</html>
Q: why not just do this as a normal form submission? At least you'd get
data posted without the intervention of JavaScript.