Off Topic

5 replies to this thread. Most Recent

David Ledger

3 Oct 2017, 11:12 am

Multiple 'onchange="submit()"'s in a form.

This is for a page that reports (WordPress) database entries according to controls presented in a form. The form controls are displayed in a one row table with up to 3 control items in a cell. Because the ‘questions’ asked depend on choices already made I want the form to auto-submit when some choices are made. I realise that this can be done with JS but this is a quick solution to a reporting deficiency and onchange=”submit()” should work.

The form was built up from the left (cell 1) and all auto-submits worked fine until I added an auto-submit checkbox to the last cell, which previously only contained a conventional ‘Submit’ button. After adding that one all of the auto-submits failed.

Is there a limit to the number of auto-submits a browser can handle? Is there something wrong with my code that could cause this?

Below is the re-formatted, annotated code as shown by Safari’s Web Inspector. (The original is all PHP generated, so nothing useful to show).

Cell 1
    <p class="left">
    <input type="radio" id="AllB" name="Show" value="All" onchange="submit()">
    <label for="AllB">Show all ownerships </label>
    </p>
+ 2 more

Cell 2 (when present) has 7 <option>s
<select name="Resort" onchange="submit()">
<option>--select--</option>
. . . 
<option value="0">None entered</option>
</select>

Cell 2/3
    <p class="left">
    <input id="FixedB" type="checkbox" name="Type[]" value="Fixed" checked="checked">
    <label for="FixedB">Fixed </label>
    </p>

Cell 3/4
<label for="email">Email only</label>
<br>
<input id="Email" type="checkbox" name="Email" onchange="submit()">
<br>
<input type="submit" name="submit">

I can’t provide a link to the page because it reveals club membership details and is passworded.

David

Todd

4 Oct 2017, 2:54 am

Not sure how to handle the checkbox in this case without js. What about adding onchange="this.form.submit();" to the checkbox field?

Untested and just a best guess.

Todd

QREATiv Community Project https://qreativ.space

David Ledger

4 Oct 2017, 3:41 pm

On 4 Oct 2017, at 3:54, Todd wrote:

Not sure how to handle the checkbox in this case without js. What about adding onchange="this.form.submit();" to the checkbox field?

Untested and just a best guess.

Todd

QREATiv Community Project https://qreativ.space

Todd

Your message also pointed out that I had forgotten the ‘;’, but even with that and the full ‘this.form.submit’ it doesn’t work.

The odd thing is that this form worked, even without the ‘;’, until I added more controls without changing the ones that were already there.

I used to have problems with ‘onchange’ last century, but that was due to different browsers needing or accepting different capitalisations of ‘onchange’.

David

Todd

4 Oct 2017, 3:51 pm

I read about some alternative solutions to the issue of onchange and checkboxes which it seems many people have had but they involve the use of images which felt very hacky, but people claim it works.

Everything else I found requires some sort of js solution.

Todd

Community Project https://qreativ.space

David Ledger wrote:

On 4 Oct 2017, at 3:54, Todd wrote:

Not sure how to handle the checkbox in this case without js. What about adding onchange="this.form.submit();" to the checkbox field?

Untested and just a best guess.

Todd

QREATiv Community Project https://qreativ.space

Todd

Your message also pointed out that I had forgotten the ‘;’, but even with that and the full ‘this.form.submit’ it doesn’t work.

The odd thing is that this form worked, even without the ‘;’, until I added more controls without changing the ones that were already there.

I used to have problems with ‘onchange’ last century, but that was due to different browsers needing or accepting different capitalisations of ‘onchange’.

David

David Ledger

6 Oct 2017, 10:28 pm

On 4 Oct 2017, at 16:40, David Ledger wrote:

On 4 Oct 2017, at 3:54, Todd wrote:

Not sure how to handle the checkbox in this case without js. What about adding onchange="this.form.submit();" to the checkbox field?

Untested and just a best guess.

Todd

QREATiv Community Project https://qreativ.space

Todd

Your message also pointed out that I had forgotten the ‘;’, but even with that and the full ‘this.form.submit’ it doesn’t work.

The odd thing is that this form worked, even without the ‘;’, until I added more controls without changing the ones that were already there.

I used to have problems with ‘onchange’ last century, but that was due to different browsers needing or accepting different capitalisations of ‘onchange’.

David

I tried viewing the page with the Epic browser and using its Inspector I see the errors:

77: <p class="left">
    <input type="radio" id="AllB" name="Show" value="All" onchange="submit();" >
    <label for="AllB" >Show all ownerships </label>
    </p>

ownershipWIP.php:77 Uncaught TypeError: submit is not a function

when I click the radio button with id ‘AllB’. And

80: <select name="Resort" onchange="this.form.submit();">
    <option >--select--</option>
    .   .   .
    <option value="0" >None entered</option>
    </select>

Uncaught TypeError: this.form.submit is not a function
onchange @ ownershipWIP.php:80

when I change the selection.

An apparently identical part of another page works, in that it submits on changing a checkbox.

?

David

Back to Top

Todd

7 Oct 2017, 10:30 pm

I’m going to see if I can replicate the form/checkbox onchange functionality locally.

Todd

Brilliant by Design https://brilliantby.design Portfolio

QREATiv https://qreativ.space Community Project

David Ledger wrote:

On 4 Oct 2017, at 16:40, David Ledger wrote:

On 4 Oct 2017, at 3:54, Todd wrote:

Not sure how to handle the checkbox in this case without js. What about adding onchange="this.form.submit();" to the checkbox field?

Untested and just a best guess.

Todd

QREATiv Community Project https://qreativ.space

Todd

Your message also pointed out that I had forgotten the ‘;’, but even with that and the full ‘this.form.submit’ it doesn’t work.

The odd thing is that this form worked, even without the ‘;’, until I added more controls without changing the ones that were already there.

I used to have problems with ‘onchange’ last century, but that was due to different browsers needing or accepting different capitalisations of ‘onchange’.

David

I tried viewing the page with the Epic browser and using its Inspector I see the errors:

77: <p class="left">
<input type="radio" id="AllB" name="Show" value="All" > onchange="submit();" >
<label for="AllB" >Show all ownerships </label>
</p>

ownershipWIP.php:77 Uncaught TypeError: submit is not a function

when I click the radio button with id ‘AllB’. And

80: <select name="Resort" onchange="this.form.submit();">
<option >--select--</option>
    .    .    .
<option value="0" >None entered</option>
</select>

Uncaught TypeError: this.form.submit is not a function
onchange @ ownershipWIP.php:80

when I change the selection.

An apparently identical part of another page works, in that it submits on changing a checkbox.

?

David