简体   繁体   中英

Select List onChange not working if the option value is “True”

I'm using MVC.net to generate a form with a select list. When the user changes the select list i want the form to automatically submit. I have the following code:

<select OnChange="$(&#39;#FormID&#39;).submit();" id="LinkedToInvoice" name="LinkedToInvoice">
    <option value="">Select</option>
    <option value="True">Yes</option>
    <option selected value="False">No</option>
</select>

Which should work and in fact it does some of the time. If i change the dropdown to "Select" it submits the form, if i change to "No" it submits the form. However when i change the dropdown to "Yes" (value = true) the form does not submit. If i change the value from True to anything else it fires correctly but the value="True" seems to stop the onchange event. Any suggestions would be most welcome.

Ok my mistake the onchange event was correctly fireing but the form submit was failing. I am using jquery ajax forms to submit the forms and i didnt include any fault checking. When the true value was passed to the server my code caused a error 500 on the server however no message was shown on the web page. Adding fault checking to my ajax form call solved the issue and allowed me to locate the cause of the error 500.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM