Forum
Auto submit on Perch Forms
Im trying to get my <perch:form> to auto submit with <perch:input type="select">. Anyone done this before? I tried with JS but cant get it to work..
<perch:form id="filter" method="get" name="hyttefilterauto">
<div class="filter-hytteserie">
<h2>Velg hytteserie</h2>
<perch:input type="select" id="hytteserie" options=", Familieserien|familieserien, Panoramaserien|panoramaserien, Oppstuguserien|oppstuguserien" onChange="hyttefilterauto.submit();" />
</div>
<div><perch:input type="submit" value="Filter" /></div>
</perch:form>
Not really an issue specific to Perch forms, it should be the same with any HTML form - see if this helps!
https://stackoverflow.com/questions/7231157/how-to-submit-form-on-change-of-dropdown-list
Something like this?
Cant get it to work. Its inside an forms html template.
Yes, something like that. As I say, this isn't really a Perch question, but maybe someone else can help out.
If you are using jQuery something like this should work:
Thanks for replying Mike. I cant get any response from the formSelect function, maybe i've done it wrong. This is my code:
I think for this to work you need to not a have a
submit
as part of the form. Try it with this removed and see if it works. In production you will want to remove it using javascript, so if someone is not running javascript they still get the submit button to useStill doesnt work. If you want to see the page live: https://tet.familiehytta.no/hyttevelger.php. Really appreciate the help.
This isn't specific to Perch - have you looked outside this forum for help?
Hmm, I think my code will only work if there is a single select in the form. I would try a reduced test case with only one select, and maybe just console log the change to test if it is working.
But as Drew says, if you post the question somewhere else e.g. Stack Overflow you will open it up to a lot more people to help you out