Dropdown menu refresh problem

Having a bit of problem with this code

      <form id="myform" method="post">
        <select name="level" onchange="change()">
<option value="Cakes">Cakes</option>
<option value="Fruits">Fruits</option>
<option value="Meat">Meat</option>        
function change(){

What it is doing, every time I select an option, it keeps going to the default selection, which is “Cakes”, since I will be submitting this form after some probably considerable time, it will give out the wrong option on clicking the “Submit” button

Can anyone tell me how to stop it resetting

Actually, every time you select an option, it submits the form immediately and reloads the page
And when page is reloaded list selects first available option again

That is what I meant

Remove the onchange call from the <select> tag and add a submit button to your form. It will then submit only when you click the submit button.

The whole point was so I called look into the folder called “Meat” and load up the images in that folder, sorry if I didn’t make that clear in the beginning

Can you show us the site, and/or the rest of your code?

It’s only on localhost at the moment, and that is all the code that is involved

So for “onchange” what you are wanting is not a “submit”, but AJAX to fetch info and then have the form updated with that info?

Basically, yes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.