Javascript could someone look this script Radiobutton with IF

F

Frank H. Shaw

Please look at the condional expersion (amount[1].checked) is it correct
written and acrurate does it do the following:

Will the conditional expersion in the if statement do the following: If the
the first
radiobutton named amount in the amount radiobutton group of two radiobuttons
at the bottom of this message is checked then the 2 lines of HTML code before
the else gets excuted if the second radio button is checked then the 2 lines
of HTML code after the ELSE get excuted. The actual radiobutton HTML code is
at the bottom of this message for you to glance at THANKS

<Script>

IF (amount[1].checked)
 
J

Jens Peter Karlsen[FP MVP]

You can not execute html. Html is markup not code.
For what you are after you would have a form with the two hidden fields
and use a script to modify their values depending on what gets selected.


Simple example:

<script type="text/javascript">
function setamount(number, curamount){
document.forms[0].item_number.value=number;
document.forms[0].amount.value=curamount;
}

<input type="checkbox" id="amount1" onclick: setamount(212-E, 20.95)>
<input type="checkbox" id="amount2" onclick: setamount(212-D, 225.00)>


Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: Frank H. Shaw [mailto:[email protected]]
Posted At: 21. maj 2005 23:19
Posted To: microsoft.public.frontpage.programming
Conversation: Javascript could someone look this script
Radiobutton with IF
Subject: Javascript could someone look this script Radiobutton with IF


Please look at the condional expersion (amount[1].checked) is
it correct written and acrurate does it do the following:

Will the conditional expersion in the if statement do the
following: If the the first radiobutton named amount in the
amount radiobutton group of two radiobuttons at the bottom of
this message is checked then the 2 lines of HTML code before
the else gets excuted if the second radio button is checked
then the 2 lines of HTML code after the ELSE get excuted. The
actual radiobutton HTML code is at the bottom of this message
for you to glance at THANKS

<Script>

IF (amount[1].checked)

ELSE

ENDIF
 
F

Frank H. Shaw

Thank you for clear up the fack that HTML is a markup and not code I have
created the Logic for what I need I know that the IF ELSE ENDIF will work
because of my years of programing behind me but what I am trying to do is get
the correct syntax for the conditional exprision which is the following:
(amount[1].checked) I beleaive I could also do the
following:(amount[1].value = 20.95) that should work also but would I have to
put "20.95" or '20.95' and what would I have if any before the amount[1]
which I assume means the first radiobutton - Please explain to me proper Opps
syntaxs and how I figure it out in the herararcy I place the exact HTMLmarkup
for the radiobuttons at the bottom of this message. Once I get a understand
of how it is done for the radiobutton I can figure it out for any object
because it is all done the same. Please use my example so I can follow it
also is what I need to do on my actual web page and I need to do it the way I
constucted the question in my first thread. THANKS


Jens Peter Karlsen said:
You can not execute html. Html is markup not code.
For what you are after you would have a form with the two hidden fields
and use a script to modify their values depending on what gets selected.


Simple example:

<script type="text/javascript">
function setamount(number, curamount){
document.forms[0].item_number.value=number;
document.forms[0].amount.value=curamount;
}

<input type="checkbox" id="amount1" onclick: setamount(212-E, 20.95)>
<input type="checkbox" id="amount2" onclick: setamount(212-D, 225.00)>


Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: Frank H. Shaw [mailto:[email protected]]
Posted At: 21. maj 2005 23:19
Posted To: microsoft.public.frontpage.programming
Conversation: Javascript could someone look this script
Radiobutton with IF
Subject: Javascript could someone look this script Radiobutton with IF


Please look at the condional expersion (amount[1].checked) is
it correct written and acrurate does it do the following:

Will the conditional expersion in the if statement do the
following: If the the first radiobutton named amount in the
amount radiobutton group of two radiobuttons at the bottom of
this message is checked then the 2 lines of HTML code before
the else gets excuted if the second radio button is checked
then the 2 lines of HTML code after the ELSE get excuted. The
actual radiobutton HTML code is at the bottom of this message
for you to glance at THANKS

<Script>

IF (amount[1].checked)

<input type="hidden" name="item_number" value="212-E"> <input
type="hidden" name="amount" value="20.95">
ELSE

<input type="hidden" name="item_number" value="212-D"> <input
type="hidden" name="amount" value="225.00">
ENDIF


<input TYPE="radio" CHECKED NAME="amount"
VALUE="20.95"> said:
style="font-size: 10.0pt; font-family: Trebuchet MS">By
each</span></p>

<input TYPE="radio" NAME="amount" VALUE="225.00"></span><span
style="font-size: 10.0pt; font-family: Trebuchet MS">By
Dozen</span></p>
 
R

Ronx

<Script>

if (document.forms[0].Ramount[1].checked) {
document.forms[0].item_number.value="212-E";
document.forms[0].amount.value="20.95";
}
else {
document.forms[0].item_number.value="212-D";
document.forms[0].amount.value="225.00"
}
</script>

<p><input TYPE="radio" CHECKED NAME="Ramount" VALUE="20.95"><span
style="font-size: 10.0pt; font-family: Trebuchet MS">By
each</span></p>
<p><input TYPE="radio" NAME="Ramount" VALUE="225.00"><span
style="font-size: 10.0pt; font-family: Trebuchet MS">By
Dozen</span></p>

Note that the radio buttons cannot have the same name as the hidden
field - radio button is named Ramount, hidden field is named amount.

See www.rxs-enterprises.org/tests/pages/prices.htm for a working
example of this.
--
Ron Symonds
Microsoft MVP (FrontPage)
Reply only to group - emails will be deleted unread.

Frank H. Shaw said:
Thank you for clear up the fack that HTML is a markup and not code I
have
created the Logic for what I need I know that the IF ELSE ENDIF will
work
because of my years of programing behind me but what I am trying to
do is get
the correct syntax for the conditional exprision which is the
following:
(amount[1].checked) I beleaive I could also do the
following:(amount[1].value = 20.95) that should work also but would
I have to
put "20.95" or '20.95' and what would I have if any before the
amount[1]
which I assume means the first radiobutton - Please explain to me
proper Opps
syntaxs and how I figure it out in the herararcy I place the exact
HTMLmarkup
for the radiobuttons at the bottom of this message. Once I get a
understand
of how it is done for the radiobutton I can figure it out for any
object
because it is all done the same. Please use my example so I can
follow it
also is what I need to do on my actual web page and I need to do it
the way I
constucted the question in my first thread. THANKS


Jens Peter Karlsen said:
You can not execute html. Html is markup not code.
For what you are after you would have a form with the two hidden
fields
and use a script to modify their values depending on what gets
selected.


Simple example:

<script type="text/javascript">
function setamount(number, curamount){
document.forms[0].item_number.value=number;
document.forms[0].amount.value=curamount;
}

<input type="checkbox" id="amount1" onclick: setamount(212-E,
20.95)>
<input type="checkbox" id="amount2" onclick: setamount(212-D,
225.00)>


Regards Jens Peter Karlsen. Microsoft MVP - Frontpage.
-----Original Message-----
From: Frank H. Shaw [mailto:[email protected]]
Posted At: 21. maj 2005 23:19
Posted To: microsoft.public.frontpage.programming
Conversation: Javascript could someone look this script
Radiobutton with IF
Subject: Javascript could someone look this script Radiobutton
with IF


Please look at the condional expersion (amount[1].checked) is
it correct written and acrurate does it do the following:

Will the conditional expersion in the if statement do the
following: If the the first radiobutton named amount in the
amount radiobutton group of two radiobuttons at the bottom of
this message is checked then the 2 lines of HTML code before
the else gets excuted if the second radio button is checked
then the 2 lines of HTML code after the ELSE get excuted. The
actual radiobutton HTML code is at the bottom of this message
for you to glance at THANKS

<Script>

IF (amount[1].checked)


<input type="hidden" name="item_number" value="212-E">
<input
type="hidden" name="amount" value="20.95">

ELSE

<input type="hidden" name="item_number" value="212-D">
<input
type="hidden" name="amount" value="225.00">

ENDIF

</script>


<input TYPE="radio" CHECKED NAME="amount"
VALUE="20.95"></span><span
style="font-size: 10.0pt; font-family: Trebuchet MS">By
each</span></p>

<input TYPE="radio" NAME="amount"
VALUE="225.00"></span><span
style="font-size: 10.0pt; font-family: Trebuchet MS">By
Dozen</span></p>
 

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

Top