Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 1 of 1
  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    18
    Member #
    27055
    I am using some javascript to produce a dependant dropdown list that gives firstly, a dropdown to select Country, when Country is selected the next dropdown will list Leagues.

    I am struggling finding a way to 'record' the selections from these dropdown lists and store them in a mySQL database.

    Could someone take a look at this code and tell me how to add a submit button that when clicked, would send the selected data to "something.php" to be manipulated and sent to a mySQL database?
    I don't need help with the php part, but just need to be able to add a Submit button that has access to the selected info.

    Here's the code I have so far:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script language="javascript" type="text/javascript">
    function dropdownlist(listindex)
    {
    
    document.formname.subcategory.options.length = 0;
    switch (listindex)
    {
    
    case "England" :
    document.formname.subcategory.options[0]=new Option("Select League","");
    document.formname.subcategory.options[1]=new Option("Premier League");
    document.formname.subcategory.options[2]=new Option("Championship");
    document.formname.subcategory.options[3]=new Option("League One");
    document.formname.subcategory.options[4]=new Option("League Two");
    document.formname.subcategory.options[5]=new Option("Conference National");
    
    break;
    
    case "Germany" :
    document.formname.subcategory.options[0]=new Option("Bundesliga");
    document.formname.subcategory.options[1]=new Option("2 Bundesliga");
    document.formname.subcategory.options[2]=new Option("3 Bundesliga");
    document.formname.subcategory.options[3]=new Option("Regionalliga");
    document.formname.subcategory.options[4]=new Option("Oberliga");
    
    break;
    
    case "Scotland" :
    document.formname.subcategory.options[0]=new Option("Premier League");
    document.formname.subcategory.options[1]=new Option("First Division");
    document.formname.subcategory.options[2]=new Option("Second Division");
    document.formname.subcategory.options[3]=new Option("Third Division");
    document.formname.subcategory.options[4]=new Option("Highland League");
    document.formname.subcategory.options[5]=new Option("East of Scotland");
    
    break;
    
    }
    return true;
    }
     
    </script>
    </head>
    <title>Dynamic Drop Down List</title>
    <body>
    
    <form id="formname" name="formname" method="post">
    <table width="50%" border="0" cellspacing="0" cellpadding="5">
    <tr>
    <td width="41%" align="right" valign="middle">Category :</td>
    <td width="59%" align="left" valign="middle"><select name="category" id="category" onchange="javascript: dropdownlist(this.options[this.selectedIndex].value);">
    <option value="">Select Country</option>
    <option value="England">England</option>
    <option value="Germany">Germany</option>
    <option value="Scotland">Scotland</option>
    </select></td>
    </tr>
    <tr>
    <td align="right" valign="middle">Sub Category :
    </td>
    <td align="left" valign="middle"><script type="text/javascript" language="JavaScript">
    document.write('<select name="subcategory"><option value="">Select Sub-Category</option>select>')
    </script>
    
    <noscript><select name="subcategory" id="subcategory" >
    <option value="">Select Sub-Category</option>
    </select>
    </noscript></td>
    </tr>
    </table>
    
    </form>
    
    </body>
    </html>

  2.  


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 05:15 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com