kraftomatic
11-03-2006, 02:30 PM
Hey Guys,
I've got the following page below. Instead of the function writing to textfields, I want to write to span tags, which will be blank to start out with, then populate with the data after the function runs. This should be simple, but I'm not getting the syntax right for some reason. Here's the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sum example</title>
<script>
var ds1 = new Spry.Data.XMLDataSet("classes.xml", "classes/class");
function sumIt(i){
var class1 = 0;
var class2 = 0;
var class3 = 0;
var x = 0;
for (x = 0; x < i; x++){
var id = (ds1.getData()[x]["class"]);
if (id == 'class1'){
class1 = class1 + 1;
}
else if(id == 'class2'){
class2 = class2 + 1;
}
else {
class3 = class3 + 1;
}
}
document.form1.textfield.value = class1;
document.form1.textfield2.value = class2;
document.form1.textfield3.value = class3;
}
</script>
</head>
<body>
<p>If correct:</p>
<ul>
<li>Class 1 = 4</li>
<li>Class 2 = 6</li>
<li>Class 3 = 7 </li>
</ul>
<form id="form1" name="form1" method="post" action="" spry:region="ds1">
<label>Class 1
<input name="textfield" type="text" size="4" />
</label>
<p>
<label>Class 2
<input name="textfield2" type="text" size="4" />
</label>
</p>
<p>
<label>Class 3
<input name="textfield3" type="text" size="4" />
</label>
</p>
</form>
<div spry:region="ds1">
<p onclick="sumIt('{ds_RowCount}');">Click Me</p>
</div>
</body>
</html>
Any suggestions would be greatly appreciated.
Thanks.
I've got the following page below. Instead of the function writing to textfields, I want to write to span tags, which will be blank to start out with, then populate with the data after the function runs. This should be simple, but I'm not getting the syntax right for some reason. Here's the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sum example</title>
<script>
var ds1 = new Spry.Data.XMLDataSet("classes.xml", "classes/class");
function sumIt(i){
var class1 = 0;
var class2 = 0;
var class3 = 0;
var x = 0;
for (x = 0; x < i; x++){
var id = (ds1.getData()[x]["class"]);
if (id == 'class1'){
class1 = class1 + 1;
}
else if(id == 'class2'){
class2 = class2 + 1;
}
else {
class3 = class3 + 1;
}
}
document.form1.textfield.value = class1;
document.form1.textfield2.value = class2;
document.form1.textfield3.value = class3;
}
</script>
</head>
<body>
<p>If correct:</p>
<ul>
<li>Class 1 = 4</li>
<li>Class 2 = 6</li>
<li>Class 3 = 7 </li>
</ul>
<form id="form1" name="form1" method="post" action="" spry:region="ds1">
<label>Class 1
<input name="textfield" type="text" size="4" />
</label>
<p>
<label>Class 2
<input name="textfield2" type="text" size="4" />
</label>
</p>
<p>
<label>Class 3
<input name="textfield3" type="text" size="4" />
</label>
</p>
</form>
<div spry:region="ds1">
<p onclick="sumIt('{ds_RowCount}');">Click Me</p>
</div>
</body>
</html>
Any suggestions would be greatly appreciated.
Thanks.