Page 2 of 2 First 12
  • Jump to page:
    #16
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0
    Hi Josh,

    Thank you for looking into this one for me. I have decided to implement a 3 select list chain mechanism for my list box instead of the javascript. I got a chained list box generator to get this sorted. I will be storing and retreiveing the list items in Mysql tables and like you said i think this will be a lot more effiecient than the code i was using...

    Thanks a lot once again for your suggestions...shall see you around...




    Originally Posted by dev.josh
    I have had a play around with it... to be honest mate.. This is the first time I have used javascripts and list items :P

    but here's whats left with what I was playing with... I am at work... so I should crack on with other things...

    NOTE: I have commented out some of your code when I was testing... just to get the list values working first.


    javascript Code:
    <!DOCTYPE html>
    <html>
        <head>
            <title>Testing...</title>
            <script type="text/javascript" src="jquery.js"></script>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <script type="text/javascript">
     
    /*
    var categories = [];
    categories["startList"] = ["CLOTHING","ELECTRONICS","AUTOMOBILES"];
    categories["CLOTHING"] = ["MEN","WOMEN","KIDS", "FEATURED STORES CLOTHING","OFFERS CLOTHING"];
    categories["ELECTRONICS"] = ["CAR/AUTO ELECTRONICS & GPS","CAMERA AND PHOTO","CELL PHONES AND ACCESSORIES","MP3 PLAYERS AND ACCESSORIES","TV,HOME THEATRE,AUDIO/VIDEO","MUSICAL INSTRUMENTS AND ACCESSORIES","VIDEO GAMES"];
    categories["AUTOMOBILES"] = ["CAR","MOTORCYCLE"];
    categories["MEN"] = ["T-shirts","Casual & Party Wear Shirts","Formal Shirts","Jeans","Cargos, Shorts & 3/4ths","Trousers","Inner & Sleep Wear","Rainwear","Sports Wear","Accessories & Combo Sets","Suits & Blazers","BRANDS MEN"];
    categories["WOMEN"] = ["Dresses & Skirts","Ethnic Wear","Shirts, Tops & Tunics","Polos & T-shirts","Jeans & Shorts", "Leggings & Jeggings","Trousers & Capris","Lingerie & Sleepwear","Accessories","BRANDS WOMEN"];
    categories["KIDS"] = ["BOYS","GIRLS","INFANTS"];
    categories["FEATURED STORES"] = ["For Men", "For Women", "For Kids"];
    categories["OFFERS"] = ["Featured Deals", "SALE"];
     
    categories["CAR/AUTO ELECTRONICS & GPS"] = ["Car Audio","Car Stereo", "Car Speakers", "Car Amplifiers","Car Subwoofers","Car Video", "Satellite Radio", "CB Radio","OTHER Car Audio & Video ","Alarm Systems", "Key-less entry", "Remote Starters", "Vehicle Back-Up Cameras","Steering Wheel Locking ","Radar Detectors", "OTHER Car Safety & Security", "Vehicle GPS" ,"GPS Mapping Software", "GPS Trackers", "GPS Systems Accessories", "Sport & Handheld GPS", "Boating GPS","OTHER GPS & Navigation",];
    categories["CAMERA AND PHOTO"] = ["Digital SLR","Point & Shoot","Advanced Point & Shoot", "Camcorder", "Mirrorless ","Brands", "SLR ACCESSORIES", "Lenses by brands", "Lens Cleaners","Lens Caps ","Filters", "Flashes", "Memory Cards" , "Tripods", "Camera Bags", "Binoculars & Optics", "Digital Photoframes", "FEATURED STORES","OFFERS"];
    categories["CELL PHONES AND ACCESSORIES"] = ["Brand cell phones","Samsung","Micromax", "Nokia", "Sony ","HTC", "Apple", "BlackBerry", "FEATURED STORES CELL PHONES AND ACCESSORIES","OFFERS CELL PHONES AND ACCESSORIES ","SERVICES"];
    categories["MP3 PLAYERS AND ACCESSORIES"] = ["Under 1GB","1 to 4 GB","5 to 24 GB", "25 to 60 GB","61 to 120 GB", "Over 120 GB","ipod", "MP3 PLAYERS","SPEAKER SYSTEMS","MP3 ACCESSORIES","HEADPHONES", "CASES"];
    categories["TV,HOME THEATRE,AUDIO/VIDEO"] = ["Home Theater Systems","Compact & Portable Audio","Speakers", "Home Audio Accessories","Headphones", "HDTVs","Blu-ray Players and Projectors", "OTHER HOME THEATER EQPMTS "];
    categories["MUSICAL INSTRUMENTS AND ACCESSORIES"] = ["Guitars","Bass Guitars","Drums & Percussion", "Keyboards", "Band & Orchestra","Folk & World Instruments","Instrument Accessories", "Studio Recording Equipment ","Top Deals"];
    categories["VIDEO GAMES"] = ["PlayStation 4","PlayStation 3", "Xbox One", "Xbox 360","Sony PSP","Mac","Sony PSP", "Digital Games", "Best-Selling Video Games","OTHER GAMES AND ACCESSORIES", ];
     
     
     
    categories["CAR"] = ["MAKE","NEW","USED", "OTHERS"];
     
    categories["MOTORCYCLE"] = ["Ducati","BMW", "Shop by Type"]
     
    var nLists = 3; // number of select lists in the set
     
    function fillSelect(currCat,currList){
    var step = Number(currList.name.replace(/\D/g,""));
    for (i=step; i<nLists+1; i++) {
    document.forms['tripleplay']['List'+i].length = 1;
    document.forms['tripleplay']['List'+i].selectedIndex = 0;
    }
    var nCat = categories[currCat];
    for (each in nCat) {
    var nOption = document.createElement('option');
    var nData = document.createTextNode(nCat[each]);
    nOption.setAttribute('value',nCat[each]);
    nOption.appendChild(nData);
    currList.appendChild(nOption);
    }
    }
     
     
     
    function init() {
    fillSelect('startList',document.forms['tripleplay']['List1'])
    }
     
    navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);
    */
    </script>
    <script type="text/javascript">
    /*
     * var catg1 = document.getElementById("List1").value;
     * var catg2 = document.getElementById("List2").value;
     * var catg3 = document.getElementById("List3").value;
    */
     
     
    </script>
        </head>
    <body>
    <div align="center" id="mainWrapper">
    <?php include_once("../template_header.php");?>
    <div id="pageContent"><br />
    <div align="right" style="margin-right:32px;"><a href="inventory_list.php#inventoryForm">+ Add New Inventory Item</a></div>
    <div align="left" style="margin-left:24px;">
    <h2>Inventory list</h2>
    <?php echo $product_list; ?>
    </div>
    <hr />
    <a name="inventoryForm" id="inventoryForm"></a>
    <h3>
    &darr; Add New Inventory Item Form &darr;
    </h3>
    <div id="dropdown">
    <form action="" name="tripleplay">
    <table width="835" border="0">
    <tr>
    <td align="right" width="205">Category : </td>
    <td width="614"><select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
    <option selected>Make a selection</option>
    </select></td>
    </tr>
    <tr>
    <td align="right" >First Subcategory : </td>
    <td><select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
    <option selected>Make a selection</option>
    </select></td>
    </tr>
    <tr>
    <td align="right">Second Subcategory : </td>
    <td><select name='List3' onchange="getValue(this.value, this.form['List2'].value,
    this.form['List1'].value)">
    <option selected >Make a selection</option>
    </select></td>
    </tr>
    </table>
    </form>
    </div>
    <form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myform" method="post">
    <table width="835" border="0">
    <tr>
    <td width="205" align="right">Product Name : </td>
    <td width="620" ><label>
    <input name="product_name" type="text" id="product_name" size="64" />
    </label></td>
    </tr>
    <tr>
    <td align="right">Product Price : </td>
    <td><label>
    $
    <input name="price" type="text" id="price" size="12" />
    </label></td>
    </tr>
     
    <tr>
    <td align="right">Product Details : </td>
    <td><label>
    <textarea name="details" id="details" cols="64" rows="5"></textarea>
    </label></td>
    </tr>
    <tr>
    <td align="right">Product Image : </td>
    <td><label>
    <input type="file" name="fileField" id="fileField" />
    </label></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>
    <input type="submit" name="button" id="button" value="Submit" />
    &nbsp;
    <input type="reset" name="reset" id="reset" value="reset" /><input name="category" type="hidden" value='<script type="text/javascript>return catg1;</script>'>
     
    <input name="first_subcategory" type="hidden" value='<script type="text/javascript>return catg2;</script>'>
     
    <input name="second_subcategory" type="hidden" value='<script type="text/javascript>return catg3;</script>'>
     
    </td>
    </tr>
    </table>
    </form>
    <FORM name="drop_list" action="NextPage.jsp" method="POST" >  
     
    <SELECT NAME="Month_list">  
    <option value="" >Month list</option>  
    </SELECT>  
     
    </FORM>  
    <script  language=javascript type="text/javascript">  
     
    var categoryA1 = new Array("CLOTHING","ELECTRONICS","AUTOMOBILES");
    var categoryA2 = new Array("MEN","WOMEN","KIDS", "FEATURED STORES CLOTHING","OFFERS CLOTHING");
     
    var selObj1 = document.forms["tripleplay"].elements["List1"];
    var selObj2 = document.forms["tripleplay"].elements["List2"];
    var selObj3 = document.forms["tripleplay"].elements["List3"];
     
     
    for (var i=0; i < categoryA1.length;++i)  
    {  
     
    addOption(selObj1, categoryA1[i], categoryA1[i]);
    }
    for (var i=0; i < categoryA2.length;++i)  
    {
    addOption(selObj2, categoryA2[i], categoryA2[i]);
    }
    function addOption(selectbox,text,value )  
    {  
     
    var optn = document.createElement("OPTION");  
    optn.text = text;  
    optn.value = value;  
    selectbox.options.add(optn);  
    }  
     
    </script>
    </body>
    </html>
    ,
  2. #17
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    20
    Rep Power
    0
    No problem mate, I'm glad you found some sort of solution... Sorry I didn't work out the answer... Was too busy doing my own thing lol... Trying to fix a laptops sound card :/

    Anyways take care
  4. #18
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2013
    Posts
    9
    Rep Power
    0
    Hi Josh,

    Thank you for looking into this one for me...I have decided to go with chained select list box and have a script for the same.

    Like you said i think that will be more effecient than what i am doing with javascript.

    Once again, Thanks a lot for your time. Will c you around...

    Originally Posted by dev.josh
    I have had a play around with it... to be honest mate.. This is the first time I have used javascripts and list items :P

    but here's whats left with what I was playing with... I am at work... so I should crack on with other things...

    NOTE: I have commented out some of your code when I was testing... just to get the list values working first.


    javascript Code:
    <!DOCTYPE html>
    <html>
        <head>
            <title>Testing...</title>
            <script type="text/javascript" src="jquery.js"></script>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <script type="text/javascript">
     
    /*
    var categories = [];
    categories["startList"] = ["CLOTHING","ELECTRONICS","AUTOMOBILES"];
    categories["CLOTHING"] = ["MEN","WOMEN","KIDS", "FEATURED STORES CLOTHING","OFFERS CLOTHING"];
    categories["ELECTRONICS"] = ["CAR/AUTO ELECTRONICS & GPS","CAMERA AND PHOTO","CELL PHONES AND ACCESSORIES","MP3 PLAYERS AND ACCESSORIES","TV,HOME THEATRE,AUDIO/VIDEO","MUSICAL INSTRUMENTS AND ACCESSORIES","VIDEO GAMES"];
    categories["AUTOMOBILES"] = ["CAR","MOTORCYCLE"];
    categories["MEN"] = ["T-shirts","Casual & Party Wear Shirts","Formal Shirts","Jeans","Cargos, Shorts & 3/4ths","Trousers","Inner & Sleep Wear","Rainwear","Sports Wear","Accessories & Combo Sets","Suits & Blazers","BRANDS MEN"];
    categories["WOMEN"] = ["Dresses & Skirts","Ethnic Wear","Shirts, Tops & Tunics","Polos & T-shirts","Jeans & Shorts", "Leggings & Jeggings","Trousers & Capris","Lingerie & Sleepwear","Accessories","BRANDS WOMEN"];
    categories["KIDS"] = ["BOYS","GIRLS","INFANTS"];
    categories["FEATURED STORES"] = ["For Men", "For Women", "For Kids"];
    categories["OFFERS"] = ["Featured Deals", "SALE"];
     
    categories["CAR/AUTO ELECTRONICS & GPS"] = ["Car Audio","Car Stereo", "Car Speakers", "Car Amplifiers","Car Subwoofers","Car Video", "Satellite Radio", "CB Radio","OTHER Car Audio & Video ","Alarm Systems", "Key-less entry", "Remote Starters", "Vehicle Back-Up Cameras","Steering Wheel Locking ","Radar Detectors", "OTHER Car Safety & Security", "Vehicle GPS" ,"GPS Mapping Software", "GPS Trackers", "GPS Systems Accessories", "Sport & Handheld GPS", "Boating GPS","OTHER GPS & Navigation",];
    categories["CAMERA AND PHOTO"] = ["Digital SLR","Point & Shoot","Advanced Point & Shoot", "Camcorder", "Mirrorless ","Brands", "SLR ACCESSORIES", "Lenses by brands", "Lens Cleaners","Lens Caps ","Filters", "Flashes", "Memory Cards" , "Tripods", "Camera Bags", "Binoculars & Optics", "Digital Photoframes", "FEATURED STORES","OFFERS"];
    categories["CELL PHONES AND ACCESSORIES"] = ["Brand cell phones","Samsung","Micromax", "Nokia", "Sony ","HTC", "Apple", "BlackBerry", "FEATURED STORES CELL PHONES AND ACCESSORIES","OFFERS CELL PHONES AND ACCESSORIES ","SERVICES"];
    categories["MP3 PLAYERS AND ACCESSORIES"] = ["Under 1GB","1 to 4 GB","5 to 24 GB", "25 to 60 GB","61 to 120 GB", "Over 120 GB","ipod", "MP3 PLAYERS","SPEAKER SYSTEMS","MP3 ACCESSORIES","HEADPHONES", "CASES"];
    categories["TV,HOME THEATRE,AUDIO/VIDEO"] = ["Home Theater Systems","Compact & Portable Audio","Speakers", "Home Audio Accessories","Headphones", "HDTVs","Blu-ray Players and Projectors", "OTHER HOME THEATER EQPMTS "];
    categories["MUSICAL INSTRUMENTS AND ACCESSORIES"] = ["Guitars","Bass Guitars","Drums & Percussion", "Keyboards", "Band & Orchestra","Folk & World Instruments","Instrument Accessories", "Studio Recording Equipment ","Top Deals"];
    categories["VIDEO GAMES"] = ["PlayStation 4","PlayStation 3", "Xbox One", "Xbox 360","Sony PSP","Mac","Sony PSP", "Digital Games", "Best-Selling Video Games","OTHER GAMES AND ACCESSORIES", ];
     
     
     
    categories["CAR"] = ["MAKE","NEW","USED", "OTHERS"];
     
    categories["MOTORCYCLE"] = ["Ducati","BMW", "Shop by Type"]
     
    var nLists = 3; // number of select lists in the set
     
    function fillSelect(currCat,currList){
    var step = Number(currList.name.replace(/\D/g,""));
    for (i=step; i<nLists+1; i++) {
    document.forms['tripleplay']['List'+i].length = 1;
    document.forms['tripleplay']['List'+i].selectedIndex = 0;
    }
    var nCat = categories[currCat];
    for (each in nCat) {
    var nOption = document.createElement('option');
    var nData = document.createTextNode(nCat[each]);
    nOption.setAttribute('value',nCat[each]);
    nOption.appendChild(nData);
    currList.appendChild(nOption);
    }
    }
     
     
     
    function init() {
    fillSelect('startList',document.forms['tripleplay']['List1'])
    }
     
    navigator.appName == "Microsoft Internet Explorer" ? attachEvent('onload', init, false) : addEventListener('load', init, false);
    */
    </script>
    <script type="text/javascript">
    /*
     * var catg1 = document.getElementById("List1").value;
     * var catg2 = document.getElementById("List2").value;
     * var catg3 = document.getElementById("List3").value;
    */
     
     
    </script>
        </head>
    <body>
    <div align="center" id="mainWrapper">
    <?php include_once("../template_header.php");?>
    <div id="pageContent"><br />
    <div align="right" style="margin-right:32px;"><a href="inventory_list.php#inventoryForm">+ Add New Inventory Item</a></div>
    <div align="left" style="margin-left:24px;">
    <h2>Inventory list</h2>
    <?php echo $product_list; ?>
    </div>
    <hr />
    <a name="inventoryForm" id="inventoryForm"></a>
    <h3>
    &darr; Add New Inventory Item Form &darr;
    </h3>
    <div id="dropdown">
    <form action="" name="tripleplay">
    <table width="835" border="0">
    <tr>
    <td align="right" width="205">Category : </td>
    <td width="614"><select name='List1' onchange="fillSelect(this.value,this.form['List2'])">
    <option selected>Make a selection</option>
    </select></td>
    </tr>
    <tr>
    <td align="right" >First Subcategory : </td>
    <td><select name='List2' onchange="fillSelect(this.value,this.form['List3'])">
    <option selected>Make a selection</option>
    </select></td>
    </tr>
    <tr>
    <td align="right">Second Subcategory : </td>
    <td><select name='List3' onchange="getValue(this.value, this.form['List2'].value,
    this.form['List1'].value)">
    <option selected >Make a selection</option>
    </select></td>
    </tr>
    </table>
    </form>
    </div>
    <form action="inventory_list.php" enctype="multipart/form-data" name="myForm" id="myform" method="post">
    <table width="835" border="0">
    <tr>
    <td width="205" align="right">Product Name : </td>
    <td width="620" ><label>
    <input name="product_name" type="text" id="product_name" size="64" />
    </label></td>
    </tr>
    <tr>
    <td align="right">Product Price : </td>
    <td><label>
    $
    <input name="price" type="text" id="price" size="12" />
    </label></td>
    </tr>
     
    <tr>
    <td align="right">Product Details : </td>
    <td><label>
    <textarea name="details" id="details" cols="64" rows="5"></textarea>
    </label></td>
    </tr>
    <tr>
    <td align="right">Product Image : </td>
    <td><label>
    <input type="file" name="fileField" id="fileField" />
    </label></td>
    </tr>
    <tr>
    <td>&nbsp;</td>
    <td>
    <input type="submit" name="button" id="button" value="Submit" />
    &nbsp;
    <input type="reset" name="reset" id="reset" value="reset" /><input name="category" type="hidden" value='<script type="text/javascript>return catg1;</script>'>
     
    <input name="first_subcategory" type="hidden" value='<script type="text/javascript>return catg2;</script>'>
     
    <input name="second_subcategory" type="hidden" value='<script type="text/javascript>return catg3;</script>'>
     
    </td>
    </tr>
    </table>
    </form>
    <FORM name="drop_list" action="NextPage.jsp" method="POST" >  
     
    <SELECT NAME="Month_list">  
    <option value="" >Month list</option>  
    </SELECT>  
     
    </FORM>  
    <script  language=javascript type="text/javascript">  
     
    var categoryA1 = new Array("CLOTHING","ELECTRONICS","AUTOMOBILES");
    var categoryA2 = new Array("MEN","WOMEN","KIDS", "FEATURED STORES CLOTHING","OFFERS CLOTHING");
     
    var selObj1 = document.forms["tripleplay"].elements["List1"];
    var selObj2 = document.forms["tripleplay"].elements["List2"];
    var selObj3 = document.forms["tripleplay"].elements["List3"];
     
     
    for (var i=0; i < categoryA1.length;++i)  
    {  
     
    addOption(selObj1, categoryA1[i], categoryA1[i]);
    }
    for (var i=0; i < categoryA2.length;++i)  
    {
    addOption(selObj2, categoryA2[i], categoryA2[i]);
    }
    function addOption(selectbox,text,value )  
    {  
     
    var optn = document.createElement("OPTION");  
    optn.text = text;  
    optn.value = value;  
    selectbox.options.add(optn);  
    }  
     
    </script>
    </body>
    </html>
Page 2 of 2 First 12
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo