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
    Member #
    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:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
    <html xmlns="">
    <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");
    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");
    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");
    return true;
    <title>Dynamic Drop Down List</title>
    <form id="formname" name="formname" method="post">
    <table width="50%" border="0" cellspacing="0" cellpadding="5">
    <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>
    <td align="right" valign="middle">Sub Category :
    <td align="left" valign="middle"><script type="text/javascript" language="JavaScript">
    document.write('<select name="subcategory"><option value="">Select Sub-Category</option>select>')
    <noscript><select name="subcategory" id="subcategory" >
    <option value="">Select Sub-Category</option>


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 02:00 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: