Jump to content

Form linking to drop-down list


Graxeon

Recommended Posts

Hey, I'm trying to make a form popup for genres after clicking an option on a drop-down list. That form has a list of different genres, creates a new JS file based on what the user selects, and sends that new JS file to the 2nd drop-down list. I can find out how to make the form, I know how to generate the JS file, but I DO NOT know how to link that new JS file (generated from a PHP script) to the 2nd drop-down list. That is my question, how do I link the newly generated JS file to the 2nd drop-down list?

 

The rest of my post is an explanation of how the drop-down lists function. This is pretty long so bear with me, please. Also, note some of the comments within the code

 

This is the first drop-down list:

 

<select onchange="drop_down_list_level_1(this.options[this.selectedIndex].value);" name="level_1">
		  <option value='main.xml'>Start Here</option>
		  <option value=''>--------</option>
		  <option value='da'>Sort Alphabetically</option>
		  <option value='dg' onClick="javascript:makeExternalPopup()">Sort by Genre</option> //the onClick value is what makes the form popup
</select>

 

My website has 3 drop-down lists (it's like a state-city-county thing). They're all linked to each other by "option value=''". Each "value" is an individual JavaScript file. So, "da" is really "da.js" and "dg" is "dg.js".

 

However, for the option on "dg" though, I want the form to popup first and THEN have the "value" link to a PHP generated JS file.

 

Here is an example of a JS file that would be generated by the form:

 

function populate(form)
{
  form.options.length = 0;
  form.options[0] = new Option("Drama, Horror, Action","");
  form.options[1] = new Option("Title1", "dglink1"); //Every "dglink#" is a JS file that comes up in Drop-down list 3.
  form.options[2] = new Option("Title2", "dglink2");
  form.options[3] = new Option("Title3", "dglink3");
  form.options[4] = new Option("Title4", "link4.xml"); //These options can link directly to an XML file, btw. Essentially, that's what it all gets down to. This, ofc, is all handled within the PHP file that generates it.
};

 

Here is the code for all 3 drop-down lists:

 

<body onload="drop_down_list_level_1(document.form.level_1.options[document.form.level_1.selectedIndex].value);"
        bgcolor="black"
	TEXT="#FFFFFF">

    <form name="form">
      <table width="0" border="0">
        <tr>
          <td width="0">
            <select onchange="drop_down_list_level_1(this.options[this.selectedIndex].value);" name="level_1">
		  <option value='main.xml'>Start Here</option>
		  
		  <option value=''>--------</option>

		  <option value='de'>Sort Alphabetically</option>
		  <option value='dg' onClick="javascript:makeExternalPopup()">Sort by Genre</option>

              <!--        L1-playlist_multiple_locations.xml -->
            </select>

          </td>
        </tr>
        <tr>
          <td>
            <div id="level_2_drop_down" class="drop_down">
              <select onchange="drop_down_list_level_2(this.options[this.selectedIndex].value);" name="level_2">

                <option value="">Level 2...</option>
              </select>
            </div>
            <span id="loading_level_2_drop_down" class="loading_drop_down">
              <img src="loader.gif" width="16" height="16" align="absmiddle">
               Loading...
            </span>
            <div id="no_level_2_drop_down" class="no_drop_down">
              <!--        This Category has no further Levels. -->
            </div>

          </td>
        </tr>
        <tr>
          <td>
            <div id="level_3_drop_down" class="drop_down">
              <select onchange="loadPlaylist(this.options[this.selectedIndex].value);" name="level_3">

                <option value="">Playlist...</option>
              </select>
            </div>
            <span id="loading_level_3_drop_down" class="loading_drop_down">
              <img src="loader.gif" width="16" height="16" align="absmiddle">
               Loading...
            </span>
            <div id="no_level_3_drop_down" class="no_drop_down">
              <!--        This Category has no Levels. -->
            </div>

          </td>
        </tr>
      </table>
    </form>

 

 

It's a bit confusing, sorry. But PLEASE help me with this...I googled it and couldn't find anything better than this: http://www.openjs.com/tutorials/advanced_tutorial/popup.php . But that doesn't answer my question on how to link a newly generated JS file to the 2nd drop-down list.

Link to comment
https://forums.phpfreaks.com/topic/186800-form-linking-to-drop-down-list/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.