473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

im a total noob, but still... what am i doing wrong?

<!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>Untitled Document</title>
<script type="text/javascript">var v11 = + $0; var v12 = + $25; var v13
= + $75 var v14 = + $100;
function f1()
{ if(document.form1.rb1[0].checked) var v11 = + $0; var v12 = + $25;
var v13 = + $75; var 1v4 = + $100; else
if(document.form1.rb1[1].checked) var v11 = - $25; var v12 = + $0; var
v13 = + $25; var v14 = + $50; else
if(document.form1.rb1[2].checked) var v11 = - $50; var v12 = - $25; var
v13 = + $0; var v14 = + $25; else
if(document.form1.rb1[3].checked) var v11 = - $75; var v12 = - $50; var
v13 = - $25; var v14 = + $0;}
</script>
</head>

<body>
<form name="form1">
<input type="radio" name="rb1" value="$799.97" checked
onclick="f1()">Computers<br/>
<input type="radio" name="rb1" value="$26.95"
onclick="f1()">Books<br/>

<input type="radio" name="rb1" value="$1.99"
onclick="f1()">Pencils<br/>
<input type="radio" name="rb1" value="$0.99"
onclick="f1()">Paper<br/>
<script type="text/javascript">
document.write(v11, v12, v13, v14)</script>
</body>
</html>

im trying to get in effect what you see on dell.com or alienware.com
when you change a computer componet like say instead of hard drive X
you choose hard drive Y all the prices change next to each componet i
know my document.write is in the wrong place to be exactly like the
dell ect. i was just trying to see if i could get it to work which i...
cant:(

Jan 6 '07 #1
6 1453
Hi Plemon,

There are a few things causing trouble.

If you
plemon wrote:
<!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>Untitled Document</title>
<script type="text/javascript">var v11 = + $0; var v12 = + $25; var v13
= + $75 var v14 = + $100;
function f1()
{ if(document.form1.rb1[0].checked) var v11 = + $0; var v12 = + $25;
var v13 = + $75; var 1v4 = + $100; else
if(document.form1.rb1[1].checked) var v11 = - $25; var v12 = + $0; var
v13 = + $25; var v14 = + $50; else
if(document.form1.rb1[2].checked) var v11 = - $50; var v12 = - $25; var
v13 = + $0; var v14 = + $25; else
if(document.form1.rb1[3].checked) var v11 = - $75; var v12 = - $50; var
v13 = - $25; var v14 = + $0;}
</script>
</head>

<body>
<form name="form1">
<input type="radio" name="rb1" value="$799.97" checked
onclick="f1()">Computers<br/>
<input type="radio" name="rb1" value="$26.95"
onclick="f1()">Books<br/>

<input type="radio" name="rb1" value="$1.99"
onclick="f1()">Pencils<br/>
<input type="radio" name="rb1" value="$0.99"
onclick="f1()">Paper<br/>
<script type="text/javascript">
document.write(v11, v12, v13, v14)</script>
</body>
</html>

im trying to get in effect what you see on dell.com or alienware.com
when you change a computer componet like say instead of hard drive X
you choose hard drive Y all the prices change next to each componet i
know my document.write is in the wrong place to be exactly like the
dell ect. i was just trying to see if i could get it to work which i...
cant:(
If you are going to use a doctype (which is good to do) then it is a
good idea to also validate you markup. <URL: http://validator.w3.org/>

If you want to use if-else blocks with multiple lines in each case then
you want to use braces around the mutiple lines with each case.

You can only use document.write while the page loads. After the page
loads you use different techniques to manipulate the page.

Strings need to be in either double or single quotation marks.

The following works but it isn't the prettiest.

May I suggest <URL: http://jibbering.com/faq/#FAQ3_1to get you going
faster if you are interested in learning JavaScript.

Peter
<!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>

<form name="form1" action="#">
<ul>
<li><input type="radio" name="rb1" value="$799.97"
checked="checked" onclick="f1()" />Computers</li>
<li><input type="radio" name="rb1" value="$26.95" onclick="f1()"
/>Books</li>
<li><input type="radio" name="rb1" value="$1.99" onclick="f1()"
/>Pencils</li>
<li><input type="radio" name="rb1" value="$0.99" onclick="f1()"
/>Paper</li>
</ul>
</form>

<span id="v11"></span>
<span id="v12"></span>
<span id="v13"></span>
<span id="v14"></span>

<script type="text/javascript">
f1();
</script>

</body>
</html>

Jan 6 '07 #2

"plemon" <kk*****@gmail.comwrote in message
news:11**********************@38g2000cwa.googlegro ups.com...
<!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>Untitled Document</title>
<script type="text/javascript">var v11 = + $0; var v12 = + $25; var v13
= + $75 var v14 = + $100;
function f1()
{ if(document.form1.rb1[0].checked) var v11 = + $0; var v12 = + $25;
var v13 = + $75; var 1v4 = + $100; else
if(document.form1.rb1[1].checked) var v11 = - $25; var v12 = + $0; var
v13 = + $25; var v14 = + $50; else
if(document.form1.rb1[2].checked) var v11 = - $50; var v12 = - $25; var
v13 = + $0; var v14 = + $25; else
if(document.form1.rb1[3].checked) var v11 = - $75; var v12 = - $50; var
v13 = - $25; var v14 = + $0;}
</script>
</head>

<body>
<form name="form1">
<input type="radio" name="rb1" value="$799.97" checked
onclick="f1()">Computers<br/>
<input type="radio" name="rb1" value="$26.95"
onclick="f1()">Books<br/>

<input type="radio" name="rb1" value="$1.99"
onclick="f1()">Pencils<br/>
<input type="radio" name="rb1" value="$0.99"
onclick="f1()">Paper<br/>
<script type="text/javascript">
document.write(v11, v12, v13, v14)</script>
</body>
</html>

im trying to get in effect what you see on dell.com or alienware.com
when you change a computer componet like say instead of hard drive X
you choose hard drive Y all the prices change next to each componet i
know my document.write is in the wrong place to be exactly like the
dell ect. i was just trying to see if i could get it to work which i...
cant:(
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){
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)">

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
Jan 6 '07 #3
thank you all yeah i know my formating i just started javascript
so i dont quite no all the rules and i always forget about the
validator
On Jan 6, 2:56 am, "Hal Rosser" <hmros...@bellsouth.netwrote:
"plemon" <kkdd...@gmail.comwrote in messagenews:11**********************@38g2000cwa.go oglegroups.com...
<!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>Untitled Document</title>
<script type="text/javascript">var v11 = + $0; var v12 = + $25; var v13
= + $75 var v14 = + $100;
function f1()
{ if(document.form1.rb1[0].checked) var v11 = + $0; var v12 = + $25;
var v13 = + $75; var 1v4 = + $100; else
if(document.form1.rb1[1].checked) var v11 = - $25; var v12 = + $0; var
v13 = + $25; var v14 = + $50; else
if(document.form1.rb1[2].checked) var v11 = - $50; var v12 = - $25; var
v13 = + $0; var v14 = + $25; else
if(document.form1.rb1[3].checked) var v11 = - $75; var v12 = - $50; var
v13 = - $25; var v14 = + $0;}
</script>
</head>
<body>
<form name="form1">
<input type="radio" name="rb1" value="$799.97" checked
onclick="f1()">Computers<br/>
<input type="radio" name="rb1" value="$26.95"
onclick="f1()">Books<br/>
<input type="radio" name="rb1" value="$1.99"
onclick="f1()">Pencils<br/>
<input type="radio" name="rb1" value="$0.99"
onclick="f1()">Paper<br/>
<script type="text/javascript">
document.write(v11, v12, v13, v14)</script>
</body>
</html>
im trying to get in effect what you see on dell.com or alienware.com
when you change a computer componet like say instead of hard drive X
you choose hard drive Y all the prices change next to each componet i
know my document.write is in the wrong place to be exactly like the
dell ect. i was just trying to see if i could get it to work which i...
cant:(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){
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)">

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
Jan 7 '07 #4
yeah i like the second response a lot although the first works i can
work the second one to my needs with less hassle and about adding them
up im going to change the values and add the values of the checked ones
instead of the variables or i will pass each value into a var and then
add the vars

On Jan 6, 2:56 am, "Hal Rosser" <hmros...@bellsouth.netwrote:
"plemon" <kkdd...@gmail.comwrote in messagenews:11**********************@38g2000cwa.go oglegroups.com...
<!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>Untitled Document</title>
<script type="text/javascript">var v11 = + $0; var v12 = + $25; var v13
= + $75 var v14 = + $100;
function f1()
{ if(document.form1.rb1[0].checked) var v11 = + $0; var v12 = + $25;
var v13 = + $75; var 1v4 = + $100; else
if(document.form1.rb1[1].checked) var v11 = - $25; var v12 = + $0; var
v13 = + $25; var v14 = + $50; else
if(document.form1.rb1[2].checked) var v11 = - $50; var v12 = - $25; var
v13 = + $0; var v14 = + $25; else
if(document.form1.rb1[3].checked) var v11 = - $75; var v12 = - $50; var
v13 = - $25; var v14 = + $0;}
</script>
</head>
<body>
<form name="form1">
<input type="radio" name="rb1" value="$799.97" checked
onclick="f1()">Computers<br/>
<input type="radio" name="rb1" value="$26.95"
onclick="f1()">Books<br/>
<input type="radio" name="rb1" value="$1.99"
onclick="f1()">Pencils<br/>
<input type="radio" name="rb1" value="$0.99"
onclick="f1()">Paper<br/>
<script type="text/javascript">
document.write(v11, v12, v13, v14)</script>
</body>
</html>
im trying to get in effect what you see on dell.com or alienware.com
when you change a computer componet like say instead of hard drive X
you choose hard drive Y all the prices change next to each componet i
know my document.write is in the wrong place to be exactly like the
dell ect. i was just trying to see if i could get it to work which i...
cant:(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){
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)">

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
Jan 7 '07 #5
Peter Michaux wrote:
<snip>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<snip>
if (document.form1.rb1[0].checked) {
^^^^^^^^^^^^^^^^^^
<snip>
<form name="form1" action="#">
<snip>

The "shortcut" property accessors of referencing a named form as a named
property of the document, and referencing a named form control as a
property of the FORM element should not be expected to be available in
XHTML DOMs. If you are going to script a DOM in a way based upon the
assumption that it will be an HTML DOM that is being scripted it makes
more sense to mark-up the document in a way that is unambiguously HTML,
not XHTML.

Richard.
Jan 7 '07 #6
Lee
plemon said:
>
yeah i like the second response a lot although the first works i can
work the second one to my needs with less hassle and about adding them
up im going to change the values and add the values of the checked ones
instead of the variables or i will pass each value into a var and then
add the vars
You'll find that you get more and better responses if it's easier
to ready what you post. Use standard punctuation and capitalization.
This isn't a chat room.
--

Jan 7 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Rich Grise | last post by:
I think I've finally found a tutorial that can get me started: http://www.zib.de/Visual/people/mueller/Course/Tutorial/tutorial.html and I've been lurking for awhile as well. What happened is,...
8
by: Peter A. Schott | last post by:
Been reading the docs saying that file should replace open in our code, but this doesn't seem to work: # Open file for writing, write something, close file MyFile = file("MyFile.txt", "w")...
4
by: foker | last post by:
I have an array with 50 elements in it, and a huge document with like 35,000 words on it. What I want to do is count the number of times each element has appeared in the document. This is what I...
0
by: Frustrated LDAP administrator | last post by:
I am trying this lesson involving DBs. "ms-help://MS.VSExpressCC.v80/MS.NETFramework.v20.en/dv_vbcnexpress/html/caf3ecbd-87f5-4748-b990-7395409a19c7.htm" I can successfully create the DB,...
7
by: Sunil Korah | last post by:
Hi, I haven't used access reports much. I have a problem in getting the total of a group. I have 3 fields, ProgName (Program name), Pname (Participant's name) and PCategory (Participant...
0
by: irtehnoob | last post by:
Hi there, I'm pretty new to c# (started up a few days ago) and I'm making a simple program, so far everything is going good except I can't figure somethine out.. hence why I'm here. Anyways, in my...
3
by: ezra | last post by:
I am trying to create an invoice program that will automatically generate an invoice based on charges entered in a subform. Sounds easy enough! I have created my Total field on subform as unbound...
1
by: Fluffy654 | last post by:
First off I am a complete noob when it comes to doing anything with servers. I'm just beginning to learn today because I need to start adding SSI to my websites. I apologise in advance if I am making...
3
by: Tom Lake | last post by:
I have Python 2.6 installed on Vista Ultimate. When I try to calculate sqrt (or any transcendental functions) I get the following error Traceback (most recent call last): File "<stdin>", line...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.