NZGames.com Forums

NZGames.com Forums (https://forums.nzgames.com/index.php)
-   Coders' Forum (https://forums.nzgames.com/forumdisplay.php?f=19)
-   -   ONCHANGE= only working in IE (https://forums.nzgames.com/showthread.php?t=87144)

MadMax 20th May 2013 14:18

ONCHANGE= only working in IE
 
Code:

<P><FORM method="GET" action="/timesheet/enter_times.php" NAME="pp">
<label for="pay_period">Select the pay period to enter hours for:</label><br>
<SELECT id="pay_period" NAME="pay_period" ONCHANGE="document.pp.submit()">
        <OPTION VALUE="1368360000" >May 13, 2013 -> May 19, 2013</OPTION>
        <OPTION VALUE="1368964800" SELECTED>May 20, 2013 -> May 26, 2013</OPTION>
</SELECT>
</FORM>

^ some really old code that is still in use, I'm guessing it only works in IE because it just ignores whatever coding issue there is. Toggling the week in the OPTION is supposed to change (submit) the page.

crocos 20th May 2013 15:38

This might help - not sure, haven't watched.
http://www.youtube.com/watch?v=7O9K_ULKOzU

Also the W3 reference page:
http://www.w3.org/TR/WCAG20-TECHS/SCR19

crocos 20th May 2013 15:53

Hmm... this might be better - basically a question & response on how to submit a form on-change from a Select:
http://stackoverflow.com/questions/1...-a-form-to-php

In short, in the onChange call out to a Javascript function rather than trying to submit directly from the form.

Farmer Joe 20th May 2013 21:20

Code:

<form method="GET" action="/timesheet/enter_times.php" name="pp" id="pp">
<label for="pay_period">Select the pay period to enter hours for:</label><br>
<select id="pay_period" name="pay_period" onchange="document.getElementById('pp').submit();">
        <option value="1368360000" >May 13, 2013 -> May 19, 2013</option>
        <option value="1368964800" selected="selected">May 20, 2013 -> May 26, 2013</option>
</select>
</form>

Note: Added id to form and used document.getElementById to get, then submit it.

MadMax 20th May 2013 21:44

^ epic. With any luck I'll give it a go tomorrow :)

crocos 20th May 2013 21:52

Bloody FarmerJoe coming in with elegant and relevant solutions.

You fucking guy! You kick my dog!

Farmer Joe 22nd May 2013 14:08

Quote:

Originally Posted by crocos
Bloody FarmerJoe coming in with elegant and relevant solutions.

You fucking guy! You kick my dog!

haha :D

EvilLumpy 23rd May 2013 17:28

this.form.submit() should do the trick without needing to add any id's.

If you've got the willpower, jquery would fix it all for ya.

crocos 23rd May 2013 23:41

Quote:

Originally Posted by EvilLumpy
this.form.submit() should do the trick without needing to add any id's.

If you've got the willpower, jquery would fix it all for ya.

You sure? "this" would refer to the Select, which does not have a form attribute.

MadMax 1st August 2013 11:32

Code:

<FORM method="GET" action="/timesheet/enter_times.php" NAME="pp" id="pp">
    <label for="pay_period">Select the pay period to enter hours for:</label><br>
    <SELECT id="pay_period" NAME="pay_period" ONCHANGE="document.getElementById('pp').submit();">
        <OPTION VALUE="{$week1}" {if $pay_period==$week1}SELECTED{/if}>{$week1|date_format} -> {$week1_end|date_format}</OPTION>
        <OPTION VALUE="{$week2}" {if $pay_period==$week2}SELECTED{/if}>{$week2|date_format} -> {$week2_end|date_format}</OPTION>
    </SELECT>
</FORM>

is what I've changed it to (and have supplied code from the php rather than from the browser), however still the same result

MadMax 1st August 2013 11:45

Quote:

Originally Posted by EvilLumpy
this.form.submit() should do the trick without needing to add any id's.

Quote:

Originally Posted by crocos
You sure? "this" would refer to the Select, which does not have a form attribute.

yeah, result is it stops working completely :)

Farmer Joe 1st August 2013 18:23

Quote:

Originally Posted by MadMax
Code:

<FORM method="GET" action="/timesheet/enter_times.php" NAME="pp" id="pp">
    <label for="pay_period">Select the pay period to enter hours for:</label><br>
    <SELECT id="pay_period" NAME="pay_period" ONCHANGE="document.getElementById('pp').submit();">
        <OPTION VALUE="{$week1}" {if $pay_period==$week1}SELECTED{/if}>{$week1|date_format} -> {$week1_end|date_format}</OPTION>
        <OPTION VALUE="{$week2}" {if $pay_period==$week2}SELECTED{/if}>{$week2|date_format} -> {$week2_end|date_format}</OPTION>
    </SELECT>
</FORM>

is what I've changed it to (and have supplied code from the php rather than from the browser), however still the same result

That doesn't look like any PHP code I've ever seen?

MadMax 26th June 2014 15:22

PEAR + Smarty


All times are GMT +13. The time now is 00:58.

Powered by Trololololooooo
© Copyright NZGames.com 1996-2023
Site paid for by members (love you guys)