Question

I have this problem with onchange:

<form class="form" action="javascript:update();">
      <select name="calendar" id="calendar" onchange = "update(); location.href = 'http://orario-preghiera.it/newsito/try.html?id=' + this.value">
            <option value = "x" selected="selected">Bologna</option>
            <option value = "y1">Other city</option>
            <option value = "y2">Other city</option>
            <option value = "y3">Other city</option>
            <option value = "y4">Other city</option>
            <option value = "y5">Other city</option>
      </select>
</form>

When I choose a option, from x (i.e. selected) to y, the URL changes to y, and is displays the contents of y for a few seconds and then returns to x (selected), but the link changes and remains. How can I stop the content?

Thanks!

Was it helpful?

Solution

Your problem is that update() function is called on every page load. Seems from the debugger that it happens from the onchange method. Anyways, I'd suggest you to change the selected attribute to the active town when the page is first requested, so that you wouldnt default to the same or remove the update from onchange on the select tag.

Also, why the hell do you have jQuery loaded twice and then you override the $ method, rendering jQuery useless.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top