0

I've been completely stumped for quite a while here. Could anyone tell me what I'm doing wrong? I have set several menus with the IDs like so:

<li><label for="website">Select Website:</label>
        <select name="website" id="website" />
            <option value="http://www.site1.com">Website 1</option>
            <option value="http://www.site2.com">Website 2</option>
            <option value="http://www.site3.com">Website 3</option>
        </select>
    </li>

and with javascript like so:

    var sd = opera.contexts.speeddial;

    var weburl = document.getElementById( 'website' );

    weburl.addEventListener( 'change', function() {
        sd.url = this.value;
    }, false );

    if ( sd.url ) {
        weburl.value = sd.url;
    }

In an attempt to change the destination of the Opera Speed Dial's URL when one clicks on it. But it does not work. I have a feeling that I've got to add some js to the main index.html, but I'm not so sure.

Wladimir Palant
  • 56,865
  • 12
  • 98
  • 126
Wontia
  • 3
  • 3

1 Answers1

1

I think you need to keep in mind what order the code will run in.. In the code above, the

if ( sd.url ) {

part runs immediately, but the code that sets sd.url will only run when you choose something in the SELECT element. Hence, when the if - part runs, sd.url will not be set yet.

Does that help?

hallvors
  • 6,069
  • 1
  • 25
  • 43