when i change the class of the form the script stops working

P

plemon

If i change the class of the form to a style, the script doesnt run
anymore, some one posted a suggestion to this script in another topic I
will get what they posted and quote it but i didnt understand what they
meant? I have a feeling if I do it his way I will get it to work but i
cant seem to understand what they were saying...

Here is the script that doesnt work if i have add a class to the form
tag i.e. class = "style23"

<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8"/>
<title>Untitled Document</title>

<script type="text/javascript">

function f1() {
var v11 = "(+ $0)";
var v12 = "(+ $25)";
var v13 = "(+ $75)";
var v14 = "(+ $100)";

if (document.form1.rb1[0].checked) {
v11 = "(+ $0)";
v12 = "(+ $25)";
v13 = "(+ $75)";
v14 = "(+ $100)";
} else if (document.form1.rb1[1].checked) {
v11 = "(- $25)";
v12 = "(+ $0)";
v13 = "(+ $25)";
v14 = "(+ $50)";
} else if (document.form1.rb1[2].checked) {
v11 = "(- $50)";
v12 = "(- $25)";
v13 = "(+ $0)";
v14 = "(+ $25)";
} else if (document.form1.rb1[3].checked) {
v11 = "(- $75)";
v12 = "(- $50)";
v13 = "(- $25)";
v14 = "(+ $0)";
}

document.getElementById("v11").innerHTML = v11;
document.getElementById("v12").innerHTML = v12;
document.getElementById("v13").innerHTML = v13;
document.getElementById("v14").innerHTML = v14;
}
</script>

</head>
<body>
<table width="456" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="221" height="283" valign="top"><form name="form1"
action="#">
<input type="radio" name="rb1" value="$799.97"
checked="checked" onclick="f1()" />
Computers <span id="v11"></span><br />
<input type="radio" name="rb1" value="$26.95" onclick="f1()"
/>
Books - <span id="v12"></span><br />
<input type="radio" name="rb1" value="$1.99" onclick="f1()"
/>
Pencils - <span id="v13"></span><br />
<input type="radio" name="rb1" value="$0.99" onclick="f1()"
/>
Paper - <span id="v14"></span>
</form>&nbsp;</td>
<td width="235" valign="top">
<br />

<br />


<script type="text/javascript">
f1();
</script>&nbsp;</td>
</tr>
</table>
</body>
</html>

Here is the suggestion i dont understand i will comment between "//'s"

"I would try to make it a little simpler by making 2 small changes.
1) Change function f1 to accept arguments you want to set vars to.
the function would look like this:
function f1(theButton,a,b,c,d){
if (theButton.checked){
// I assume that he means document.form1.rb1[X].checked //
var v11 = a;
var v12 = b;
var v13 = c;
var v14 = d;
}
}

2)Change the input tags so you pass the radio button (this) to the
function
as well as the other values..
<input type="radio" name="rb1" value="799.97" checked="checked"
onclick
= "f1(this,0,25,75,100)">
<input type="radio" name="rb1" value="799.97" onclick =
"f1(this,25,0,25,50)">
<input type="radio" name="rb1" value="799.97" onclick =
"f1(this,50,25,0,25)">
<input type="radio" name="rb1" value="799.97" onclick =
"f1(this,75,50,25,0)">

// In the above I dont understand what goes where he wrote "this"//

Also I would leave the dollar sign and other formatting off untill you
display it in case you want to perform any math with the values.
HTH"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top