Jump to content

W3CSS button does not submit the page


gordonisnz
 Share

Recommended Posts

hello. I have a html form designed using W3CSS. There is a SELECT field which I have used an ONCHANGE command, & this submits the form when the select is changed.

HOWEVER, the button, does not submit the form. It just moves the page to the DIV anchor.

At the top of the page I have the current time - hh:mm:ss.  When I press the w3blue button, (select animal) the page moves, so the 'menu' div is at the top of the visible page, However the clock/time at the top doesn't change.

<form class="w3-container" action="/animals/#menu">
<select class="w3-select" name="viewpet"  onchange="this.form.submit()">
<option value="">Select Animal</option>
<option value="220000001" selected="selected">220000001, cat, Jerry, (m) scottish_fold</option>
<option value="220000002" >220000002, cat, Jerry, (f) toyger</option>
</select>
<button class="w3-btn w3-blue">Select Animal</button>
</form>

I'm going to add a few extra input values/fields in, But what do I do to fix the form so the blue button actually submits the page & refreshes it..? 

i am following this website. 

https://www.w3schools.com/w3css/w3css_input.asp

(Half the examples don't even have a submit button to test...) 

 

EDIT: ive got a 2nd form on the same page, the submit button is exactly the same (very similar) - Both forms have no ID's etc - no names.. It just submits "this form".

 

I'm not sure why 1 form works & one form doesn't.  (the div ID is above both the forns - To see part of the visible page I want folk directed to.. BOTH forms go to the sane page/div ID. )
 

Edited by gordonisnz
Link to comment
Share on other sites

By default, a page submission reloads the page and resets the inputs to default values. Onchange will do this and when reloaded and you press the blue button, no onchange has occured, so the value remains to the default set selected attribute value. The URL in address bar should reflect this, as with no method it defaults to 'get'. To read the value passed by form submission you need server language to read and store submitted data in server language variable.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...