Solved

Javascript or Jquery

Posted on 2011-03-22
6
265 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
  • 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
change car movement from jumping to swapping 8 99
Node.js 6 220
expanding and collapsing jquery 1 195
sort JSON using parameters from links 2 99
Knowing where your website is hosted is as important as the features you receive, the monthly fee, and the support you receive. Due diligence should be done when choosing your next hosting provider.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

832 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