LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   for loop inside select box (https://www.linuxquestions.org/questions/programming-9/for-loop-inside-select-box-302822/)

opioid 03-17-2005 12:43 PM

for loop inside select box
 
Whatup LQ, I have a pretty easy question for all you JS heads out there--

I'm getting a list of days of the week from MySQL DB inside a select box for an edit information page that involves an UPDATE; query, so the select looks like this:

01
02
03
04
05
06
{...}

How can I have it so that when the page loads up, the correct index value is selected in teh dropdown? For instance, if today is the 2nd of July, "02" is given the "selected" attribute...

Right now, I have it so that when I load up the page the correct and proper index only gets the selected attribute after I hit "refresh". In Firefox, that is.

basically i think it's something similar to onchange=location=this.options[this.selectedIndex].value;

but i'm sick of banging my head against teh wall tryin to figure it out. Any help is mucho appreciado, as always

Thanks,
O

TheLinuxDuck 03-17-2005 02:22 PM

The BODY HTML tag supports the javascript call onLoad. Simple call the option list fill function from there. That should solve the problem. (=


All times are GMT -5. The time now is 07:04 AM.