PDA

View Full Version : Going from javascript drop down menu to php file handling for download


chadhutchins
05-22-2007, 07:31 PM
Ok this is going to be kind of long.

On a web page I have 2 drop down menus for year and month then a submit button. This is handeled through javascript

function fillCategory(){
// this function is used to fill the category list on load
addOption(document.drop_list.Category, "2007", "2007", "");
addOption(document.drop_list.Category, "2006", "2006", "");
addOption(document.drop_list.Category, "2005", "2005", "");
}

function SelectSubCat(){
// ON selection of category this function will work

removeAllOptions(document.drop_list.SubCat);
addOption(document.drop_list.SubCat, "", "Select Month", "");

if(document.drop_list.Category.value == '2007'){
addOption(document.drop_list.SubCat,"January", "January");
addOption(document.drop_list.SubCat,"February", "February");
addOption(document.drop_list.SubCat,"March", "March");
addOption(document.drop_list.SubCat,"April", "April");
addOption(document.drop_list.SubCat,"May", "May");
}
if(document.drop_list.Category.value == '2006'){
addOption(document.drop_list.SubCat,"January", "January");
addOption(document.drop_list.SubCat,"February", "February");
addOption(document.drop_list.SubCat,"March", "March");
addOption(document.drop_list.SubCat,"April", "April");
addOption(document.drop_list.SubCat,"May", "May");
addOption(document.drop_list.SubCat,"June", "June");
addOption(document.drop_list.SubCat,"July", "July");
addOption(document.drop_list.SubCat,"August", "August");
addOption(document.drop_list.SubCat,"September", "September");
addOption(document.drop_list.SubCat,"October", "October");
addOption(document.drop_list.SubCat,"November", "November");
addOption(document.drop_list.SubCat,"December", "December");
}
if(document.drop_list.Category.value == '2005'){
addOption(document.drop_list.SubCat,"January", "January");
addOption(document.drop_list.SubCat,"February", "February");
addOption(document.drop_list.SubCat,"March", "March");
addOption(document.drop_list.SubCat,"April", "April");
addOption(document.drop_list.SubCat,"May", "May");
addOption(document.drop_list.SubCat,"June", "June");
addOption(document.drop_list.SubCat,"July", "July");
addOption(document.drop_list.SubCat,"August", "August");
addOption(document.drop_list.SubCat,"September", "September");
addOption(document.drop_list.SubCat,"October", "October");
addOption(document.drop_list.SubCat,"November", "November");
addOption(document.drop_list.SubCat,"December", "December");
}

}
//////////////////

function removeAllOptions(selectbox)
{
var i;
for(i=selectbox.options.length-1;i>=0;i--)
{
//selectbox.options.remove(i);
selectbox.remove(i);
}
}


function addOption(selectbox, value, text )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;

selectbox.options.add(optn);
}
7

On the web page:

<SELECT NAME="Category" onChange="SelectSubCat();" >
<Option value="">Select Year</option>
</SELECT>&nbsp;
<SELECT id="SubCat" NAME="SubCat">
<Option value="">Select Month</option>
</SELECT>
<input type="submit" value="Order">
</center>

Now from there I have files on an FTP server, so based on the user selection, I want php to do whatever it needs to do to get the file and prompt the user for download as it loads a new this is what you downloaded new page.

I can understand if this might not make sense, so send me any questions you may have. It's been a long day here at work trying to figure this out and my knowledge of php is not none but somewhat little.