Solved

Javascript or Jquery

Posted on 2011-03-22
6
269 Views
Last Modified: 2012-05-11
Have 3 radio buttons with prices  and display then in a div as sub total. Every product has different shipping options. Would like that price to be also added to hidden text box input


Looking for something like this http://www.wnews9.com/evin-sandbox/melatrol.com/order-page/order-page.php
0
Comment
Question by:ninjadude12
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 

Author Comment

by:ninjadude12
ID: 35195827
thanks
0
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 35195860
check this simple one
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<script src="jquery-1.4.2.min.js"></script>
	<script>
		$(document).ready(function(){
			$("input[name='radioPrice']").bind("click", function(){
				$("#subtotal").html("Subtotal is " + $(this).val());
			});
		});

	</script>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
	Option1 <input type="radio" id="radio1" value="$149.95" name="radioPrice"/>149.95 <br/>
	Option2 <input type="radio" id="radio2" value="$49.95" name="radioPrice"/>49.95<br/>
	Option3 <input type="radio" id="radio3" value="$99.95" name="radioPrice"/>99.95<br/>

	<span id="subtotal"></span>

</BODY>
</HTML>

Open in new window

0
 

Author Comment

by:ninjadude12
ID: 35195969
this does not do anything...

would like 3 options in radio and for each option chosen separate shipping options.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 40

Expert Comment

by:gurvinder372
ID: 35196045
try this then
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<script src="jquery-1.4.2.min.js"></script>
	<script>
		$(document).ready(function(){
			$("input[name='radioPrice']").bind("click", function(){
				$("#options").show();
				$("#subtotal").html("Subtotal is " + $(this).val());

				switch( $(this).index() )
				{
					case 0:
						$("#options").html("<option value='31.88'>Rush Delivery 31.88</option><option value='12.88'>Standard Delivery 12.88</option>");
					break;

					case 1:
						$("#options").html("<option value='51.88'>Rush Delivery 51.88</option><option value='32.88'>Standard Delivery 32.88</option>");
					break;

					case 2:
						$("#options").html("<option value='71.88'>Rush Delivery 71.88</option><option value='52.88'>Standard Delivery 52.88</option>");
					break;
				}
			});
		});

	</script>
</HEAD>

<BODY>
	Option1 <input type="radio" id="radio1" value="$149.95" name="radioPrice"/>149.95 <br/>
	Option2 <input type="radio" id="radio2" value="$49.95" name="radioPrice"/>49.95<br/>
	Option3 <input type="radio" id="radio3" value="$99.95" name="radioPrice"/>99.95<br/><br/>

	<span id="subtotal"></span><br/><br/>

	Choose a Shipping option: <select id="options"><option value=""><----Select an option above----></option></select>
</BODY>
</HTML>

Open in new window

0
 

Author Comment

by:ninjadude12
ID: 35198856
gurvinder372 this is very close I have it here http://www.evinw.com/jquery-order-page/index.html

but when you hit option 3 the shipping does not work. Also on that page the total is not coming out on the input box as well. Need one like its there and one in a input to put in form.
0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 35249222
sorry for the delayed reply,

Replace the line 6-26 by

$(document).ready(function(){
                  $("input[name='radioPrice']").bind("click", function(){
                        $("#options").show();
                        $("#subtotal").html("Subtotal is " + $(this).val());

                                var value = $('input:radio[name='radioPrice']:checked').val();


                        switch( value  )
                        {
                              case "$149.95":
                                    $("#options").html("<option value='31.88'>Rush Delivery 31.88</option><option value='12.88'>Standard Delivery 12.88</option>");
                              break;

                              case "$49.95":
                                    $("#options").html("<option value='51.88'>Rush Delivery 51.88</option><option value='32.88'>Standard Delivery 32.88</option>");
                              break;

                              case "$99.95":
                                    $("#options").html("<option value='71.88'>Rush Delivery 71.88</option><option value='52.88'>Standard Delivery 52.88</option>");
                              break;
                        }
                  });
            });
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Gain an elementary understanding of Blockchain technology.
Popular third-party chat platforms like Slack, Discord, and Telegram are just a few of the many new productivity applications that are being hijacked by cybercriminals to create command-and-control (C&C) communications infrastructures for their malw…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question