Jump to content

Dynamic drop down menu selection added to database


fat creative

Recommended Posts

I have a dynamic menu in a form where the user makes a selection in the first drop down and their choice populates the 2nd drop down. It was written in javascript and works great.  What I can't figure out is how to get the selection the user makes written to my database.  I have worked with array's before, but this one looks a bit different to me and I quite figure out what to do. If anyone could offer any direction, I would so appreciate it!

 

The page with the form is at http://174.34.155.2/~farmers/join.php and the drop down is under the date / location section.

 

The javascript section looks like this....

 

team = new Array(

new Array(

new Array("January 12"),

new Array("January 19"),

new Array("January 26"),

new Array("February 2")

),

new Array(

new Array("January 10"),

new Array("January 17"),

new Array("January 24"),

new Array("January 31")

),

new Array(

new Array("January 10", 23840238),

new Array("January 17", 92390484),

new Array("January 24", 29048203),

new Array("January 31", 29345423)

),

new Array(

new Array("January 10", 23840238),

new Array("January 17", 92390484),

new Array("January 24", 29048203),

new Array("January 31", 29345423)

),

new Array(

new Array("January 10", 20394802),

new Array("January 17", 34982039),

new Array("January 24", 92348902),

new Array("January 31", 98234902)

)

);

function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {

var i, j;

var prompt;

// empty existing items

for (i = selectCtrl.options.length; i >= 0; i--) {

selectCtrl.options = null;

}

prompt = (itemArray != null) ? goodPrompt : badPrompt;

if (prompt == null) {

j = 0;

}

else {

selectCtrl.options[0] = new Option(prompt);

j = 1;

}

if (itemArray != null) {

// add new items

for (i = 0; i < itemArray.length; i++) {

selectCtrl.options[j] = new Option(itemArray[0]);

if (itemArray[1] != null) {

selectCtrl.options[j].value = itemArray[1];

}

j++;

}

// select first item (prompt) for sub list

selectCtrl.options[0].selected = true;

  }

}

//-->

 

Thanks!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.