www.webdeveloper.com
Results 1 to 2 of 2

Thread: Help With Multiple Instances of 3 Javacripts?

  1. #1
    Join Date
    Apr 2004
    Location
    US
    Posts
    44

    Help With Multiple Instances of 3 Javacripts?

    Hello:

    I have 3 javascripts running the form for the 'Labrador Retriever' section of the following page: BTW, the forms pass to a shopping cart. All forms work GREAT in this example:

    http://www.familycarstickers.us/dogo..._20_atc_hc.htm

    Here's where the trouble starts I want to apply these same JS to another 19 'breeds' of dogs with the same form features on this same page:

    Here's my failed attempt at trying to add another breed (terrier) with the same features of the first, all while trying to pass FULL info to the cart - price, options and price-adjusting options.

    http://www.familycarstickers.us/dogo...20_atc_hc2.htm

    The 3 Javascripts are as follows...I'm not a scripter, obviously, been working at this for a few days and have some great help, but need the functoinality described. Thanks for any clues? LS


    <script Language="JavaScript">
    <!--
    function confirm_p1()
    {

    // Check to see if the dropdown value is is the first choice
    if (the_form.p1.selectedIndex == 0)
    {

    // If the first choice is selected display an alert box
    // stating the first choice is not a valid selection
    alert("Please Select a Design");

    // Focus on the dropdown menu after OK is clicked from the alert box
    the_form.p1.focus();
    return (false);
    }
    // A choice other than the first was selected
    // cotinue processing the form request
    return (true);
    }
    //--></script>


    <script type="text/javascript">

    var Labrador = [
    'Select|http://www.familycarstickers.us/deca...radorret1G.gif',
    'Design #1|http://www.familycarstickers.us/deca...bradorret1.gif',
    'Design #2|http://www.familycarstickers.us/deca...bradorret2.gif',
    'Design #3|http://www.familycarstickers.us/deca...bradorret3.gif' // NOTE: no comma after last entry
    ];

    var YorkshireTerrier = [
    'Select|http://www.familycarstickers.us/deca.../terrier1G.gif',
    'Design #4|http://www.familycarstickers.us/deca...s/terrier1.gif',
    'Design #5|http://www.familycarstickers.us/deca...s/terrier2.gif',
    'Design #6|http://www.familycarstickers.us/deca...s/terrier3.gif'
    ];

    var GermanShepherd = [
    'Select|http://www.familycarstickers.us/deca...Shepherd1G.gif',
    'Design #7|http://www.familycarstickers.us/deca...nShepherd1.gif',
    'Design #8|http://www.familycarstickers.us/deca...nShepherd2.gif',
    'Design #9|http://www.familycarstickers.us/deca...nShepherd3.gif'
    ];

    var Beagle = [
    'Select|http://www.familycarstickers.us/deca...Shepherd1G.gif',
    'Design #13|http://www.familycarstickers.us/decalimages/beagle1.gif',
    'Design #14|http://www.familycarstickers.us/decalimages/beagle2.gif',
    'Desing #15|http://www.familycarstickers.us/decalimages/beagle3.gif'
    ];


    function Populate(IDS,Arr) {
    var f=document.getElementById(IDS);
    document.getElementById(IDS).options.length=null;
    for (i=0; i<Arr.length; i++) {
    tmp = Arr[i].split('|');
    document.getElementById(IDS).options[i]=new Option(tmp[0], tmp[0]);
    }
    }

    function selectForm(obj) {
    var IDS = obj.id;
    var divIDS = obj.selectedIndex;
    // document.getElementById('test').innerHTML = IDS+' | '+divIDS; // for testing purposes only
    document.getElementById('img'+IDS).src = window[IDS][divIDS].split('|')[1];
    }

    </script>

    <script language="JavaScript"
    type="text/javascript">
    <!--
    function showHideTextfield(selIndex,frm){
    for (var i=3;i<=3;i++){
    if(selIndex<=i-3){
    frm['p'+i].disabled=true;
    }
    else{
    frm['p'+i].disabled=false;
    }
    }
    }
    //-->
    </script>

    </script>

  2. #2
    Join Date
    Sep 2008
    Location
    Mexico
    Posts
    786
    Quote Originally Posted by luckysigns View Post
    <script type="text/javascript">
    <!--
    function showHideTextfield(selIndex,frm){
    for (var i=3;i<=3;i++){
    if(selIndex<=i-3)
    {
    frm['p'+i].disabled=true;
    }
    else{
    frm['p'+i].disabled=false;
    }
    }
    }
    //-->
    </script>

    </script>
    At a glance, looks like the total number of entries needs to be changed to reflect your new number of entries...
    ...but stupidity is terminal.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles