1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

A little help required urgently

Discussion in 'jQuery' started by hallianonline, Dec 4, 2013.

  1. #1
    I am creating a little template for my website but getting an error i think so in jquery actually i want to repeat the price terms toggle option multiple times on a single page e.g. 1 month 6 months 12 months term. All is ok but on 2nd tab when i select any option it comes the first group moves and merge into the second group i tried to find out but nothing works for me Here is the example og the error. Kindly help me in this
    Before:
    before.jpg

    After:
    after.jpg

    Here is my code:

    JS

    Code (Text):
    1.         <script type="text/javascript">
    2. $(document).ready(function() {
    3.     $("div.desc").hide();
    4.     $("div.shared-page-tables-4colmns-button").show();
    5.     $("input[name$='sharedprices']").click(function() {
    6.         var test = $(this).val();
    7.         $("div.desc").hide();
    8.         $("#initial").hide();
    9.         $("#" + test).show();
    10.     });
    11. });
    12. </script>

    HTML Code:
    HTML:
    1.  <div class="shared-price-change-main">
    2.                             <ul>
    3.                             <li><input type="radio" name="sharedprices" value="basicterm1"  /> 1 Month <b>$1.99</b>/mo</li>
    4.                             <li><input type="radio" name="sharedprices" value="basicterm2" / 1 /> 6 Months <b>$1.99</b>/mo</li>
    5.                             <li><input type="radio" name="sharedprices" value="basicterm3" / 1 /> 12 Months <b>$1.99</b>/mo</li>
    6.                             </ul>
    7.                         </div>
    8.                                                   <div id="myRadioGroup" class="shareddetailsplan">
    9.                                     <div id="basicterm1" class="desc">
    10.                                     <label>You Save 0</label>
    11.                                     <div class="shared-page-tables-4colmns-button"><a href="http://google.com">Order Now</a></div>
    12.                                     </div>
    13.                                     <div id="basicterm2" class="desc">
    14.                                     <label>You Save 5%</label>
    15.                                     <div class="shared-page-tables-4colmns-button"><a href="http://msn.com">Order Now</a></div>
    16.                                     </div>
    17.                                     <div id="basicterm3" class="desc">
    18.                                     <label>You Save 10%</label>
    19.                                     <div class="shared-page-tables-4colmns-button"><a href="http://msn.com">Order Now</a></div>
    20.                                     </div>
    21.                                     <div class="shared-page-tables-4colmns-button" id="initial"><label>You Save $0</label><a href="#">Order Now</a></div>
    22.                         </div>
    23.  
    24.  
    25.  
    26.  
    27.  
    28. <div class="shared-price-change-main">
    29.                             <ul>
    30.                             <li><input type="radio" name="sharedprices" value="standardterm1"  /> 1 Month <b>$1.99</b>/mo</li>
    31.                             <li><input type="radio" name="sharedprices" value="standardterm2" / 1 /> 6 Months <b>$1.99</b>/mo</li>
    32.                             <li><input type="radio" name="sharedprices" value="standardterm3" / 1 /> 12 Months <b>$1.99</b>/mo</li>
    33.                             </ul>
    34.                         </div>
    35.                                                   <div id="myRadioGroup" class="shareddetailsplan">
    36.                                     <div id="standardterm1" class="desc">
    37.                                     <label>You Save 0</label>
    38.                                     <div class="shared-page-tables-4colmns-button"><a href="http://google.com">Order Now</a></div>
    39.                                     </div>
    40.                                     <div id="standardterm2" class="desc">
    41.                                     <label>You Save 5%</label>
    42.                                     <div class="shared-page-tables-4colmns-button"><a href="http://msn.com">Order Now</a></div>
    43.                                     </div>
    44.                                     <div id="standardterm3" class="desc">
    45.                                     <label>You Save 10%</label>
    46.                                     <div class="shared-page-tables-4colmns-button"><a href="http://msn.com">Order Now</a></div>
    47.                                     </div>
    48.                                     <div class="shared-page-tables-4colmns-button" id="initial"><label>You Save $0</label><a href="#">Order Now</a></div>
    49.                         </div>
    hallianonline, Dec 4, 2013 IP
  2. sibivarman

    sibivarman Greenhorn

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #2
    I think its its because of the name attribute. Have you tried changing the name for the two groups into different .
    sibivarman, Dec 6, 2013 IP
  3. hallianonline

    hallianonline Greenhorn

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #3
    yes but nothing is working
    hallianonline, Dec 6, 2013 IP
  4. deathshadow

    deathshadow Prominent Member

    Messages:
    5,980
    Likes Received:
    827
    Best Answers:
    144
    Trophy Points:
    395
    #4
    Uhm... I have some silly questions...

    What makes those radio buttons be list items? Why don't they have labels? Where are your fieldsets? Why do you have labels without corresponding form elements (since that's what labels are FOR)? Dragging that markup kicking and screaming into something remotely resembling semantics would probably go a long ways towards making whatever it is you're trying to do simpler...

    As to your problem, could you better explain what you want that scripting to actually do as I'm just not getting it. Looks like you're using jquery's stupid show/hide crap for ... well, I'm not even sure what. Like most of the needlessly cryptic jQuery garbage, I get a headache just looking at that mess.
    deathshadow, Dec 7, 2013 IP
  5. hallianonline

    hallianonline Greenhorn

    Messages:
    82
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    18
    #5
    if you look in this http://jsfiddle.net/VXK9t/ the code is here
    but the problem is how can i separate You Save % and Order now button for each radio group actually "the plans repeats multiple times for 3 time or 4 time and I require these 3 plan terms for each plan please help
    hallianonline, Dec 7, 2013 IP
  6. deathshadow

    deathshadow Prominent Member

    Messages:
    5,980
    Likes Received:
    827
    Best Answers:
    144
    Trophy Points:
    395
    #6
    I ALMOST think I'm grasping what you're trying to do, while at the same time feeling like I'm guessing wildly. I think the problem is your markup doesn't even come CLOSE to what you want to do or how it should be done, and you've violating one of the unwritten rules of good scripting when it comes to forms -- particularly things like order forms... If you can't make the page work without scripting FIRST, you have no business adding scripting to it.

    I SUSPECT you should have three separate forms, your anchors should be INPUT[submit], with your radio buttons properly in fieldsets. The only thing I'd have there for a scripting assist would be the % show part, which I'd do by copying a title attribute from the selected input[radio].

    Instead you don't even HAVE a form, or submits, and seem to be screwing around with a bunch of scripting for nothing.

    Though I'm still not sure I'm even understanding what you are trying to do. Might be a language barrier issue. Might also be I'm not seeing enough of the page -- are there headings/related data to those columns of buttons?!?
    deathshadow, Dec 7, 2013 IP