Skip navigation
ChitChatterz
Currently Being Moderated

Need help with some code

Feb 19, 2014 3:41 PM

Tags: #cs6

<!doctype html>

<html>

 

 

Hello,

I am quite a newbie to dreamweaver however i have managed to create my own custom price calculator, however how can i redirect the user to a specific url if the div id for total is a amount for example £540 go to a site, £440 go to another side.

How could i incorporate that?
Could somebody please help me

 

Here is the link since i cant paste it here:

http://justpaste.it/egur

 
Replies
  • Currently Being Moderated
    Feb 19, 2014 4:13 PM   in reply to ChitChatterz

    Do you want the visitor to immediately go to the desired page on clicking the radio button?

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 20, 2014 5:48 AM   in reply to ChitChatterz

    Try this (without the jQuery part)...

     

    <!doctype html>

    <html>

    <head>

    <title>Whatever</title>

    </head>

    <body>

    <a href="index.html"><img src="images/logo.jpg" width="100" height="100"></a>

    <form action="" method="">

    <label><input type="checkbox" class="option" value="200" /> Some option</label><br/>

    Please select a option??

    <label><input type='radio' class="option" name='ram_radio' value='100' onclick="document.getElementById('total').innerHTML='£' + 40;document.getElementById('button').innerHTML='<a href=&quot;page1.html&quot;>go</' + 'a>'">2 GB</label>

    <label><input type='radio' class="option" name='ram_radio' value='150' onclick="document.getElementById('total').innerHTML='£' + 60;document.getElementById('button').innerHTML='<a href=&quot;page2.html&quot;>go</' + 'a>'">3 Gb</label>

    <label><input type='radio' class="option" name='ram_radio' value='200' onclick="document.getElementById('total').innerHTML='£' + 120;document.getElementById('button').innerHTML='<a href=&quot;page3.html&quot;>go</' + 'a>'">8 Gb</label>

    <button id="button"><a>go</a></button>

    <div id="apDiv1" style="font-size:40px;color:red;">

          <div id="total"></div>

    </div>

    </form>

    </body>

    </html>

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 20, 2014 6:24 AM   in reply to ChitChatterz

    You can do this by adding to the jQuery:

     

    <script>

     

    $(document).ready(function(){

    $('label').click(function() {

    var total = 0;

    $('#total').html('£' + total);

    $('.option:checked').each(function(){

    total += parseInt($(this).val());

    });

    $('#total').html('£' + total);

    });

     

     

    $('#checkout').click(function() {

    var sum = $('#total').text();

    if(sum == "£66") {

    var url = "http://www.itv.co.uk";

    $(location).attr('href',url);

    }

    if(sum == "£100") {

    var url = "http://www.bbc.co.uk";

    $(location).attr('href',url);

    }

    if(sum == "£150") {

    var url = "http://www.dailymail.co.uk";

    $(location).attr('href',url);

    }

    if(sum == "£200") {

    var url = "http://www.thisismoney.co.uk";

    $(location).attr('href',url);

    }

        });

     

    });

     

     

    </script>

     

     

    Then including a 'checkout' button on your page:

     

     

    <input type="button" id="checkout" value="Checkout">

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 20, 2014 8:29 AM   in reply to ChitChatterz

    Just change the lines of code below to the appropriate page name:

     

    var url = "page3.html";

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2014 2:42 AM   in reply to ChitChatterz

    I don't understand what you mean by 'different texts':

     

    'Basically a radio box must have price £20 and £30 at the same time on different texts'.

     

    Can you explain what it is that you require to happen because I'm confused after reading your two previous posts.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2014 3:34 AM   in reply to ChitChatterz

    Despite your best try I'm still failing to visualize what is meant to be happening.

     

    I understand that you have a set of radio buttons on your page which represent a range of prices. When a radio button is clicked the price is display in a <div>

     

    What is this code a+b refering to? How is that associated with the price displayed on screen?

     

    Maybe someone else will read the post and understand clearly what you require. Without some visual guidance I'm not sure anyone will understand.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2014 4:05 AM   in reply to ChitChatterz

    Can you paste the page code that you currently have. Your 2 previously posted codings are different to what you describe in your most recent post.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2014 4:40 AM   in reply to ChitChatterz

    So when you click Intel 5 the letter A is displayed on the page.

     

    When you click 8Gb the amount £30 is displayed on the page.

     

    How do you want to combine these - for what purpose. The user has to select 2 options as a default from what I can see, right?

     

    Are you wanting to send the user to a specific page based on the 'letter' and the 'price'

     

    If that is the case:

     

    $('#checkout').click(function() {

    var total = $('#total').text();

    var total2 = $('#total2').text();

    if(total == "£30" && total2 == "a") {

    var url = "http://www.itv.co.uk";

    $(location).attr('href',url);

    }

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2014 4:51 AM   in reply to ChitChatterz

    ChitChatterz wrote:

     

    Hey

    I want it like,

    When i click Intel 5 the letter A to be displayed on the page alongside with the price £30.

    So if i click Intel 5 i want to see the price £30 and show letter a.

     

     

    Amend the code like below: When you click Intel 5 an A and the price £30 will appear on your page. Whats the 8Gb radio button for?

     

     

    $('.code:checked').each(function(){

    total2 += String($(this).val())

    });

    $('#total2').html(total2);

    if (total2 == "a") {

    var total = "£30";

    $('#total').html(total);

    }

    });

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2014 5:40 AM   in reply to ChitChatterz

    Without knowing the full background of your exact requirements it's not possible to give you any definitive answers only to say if I had 900 options I would probably somehow involve a database.

     
    |
    Mark as:
  • Currently Being Moderated
    Feb 21, 2014 3:58 PM   in reply to ChitChatterz

    It's not entirely clear to me what your goal is with this.  But it sure looks like you need a professional shopping cart.

     

     

    Nancy O.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)