select box - using refresh to select same item twice

E

entfred

I was experimenting with trying to select the same item in a select box
twice in a row
and found out that you need to do a refresh (view - refresh) in
Internet Explorer. This is
so you can click on the same item twice "in a row" to select it.

Does anyone know how to automatically make a web page do a refresh when
the web
page loads? This would prevent the user from having to do the refresh,
themselves.

An example select box would be

<select name="colors" onChange="form1.submit();">
<option value="red">red</option><option
value="blue">blue</option><option value="green">green</option><option
value="purple">purple</option>
</select>

A typical scenario:

1. The user clicks on blue
2. form1 is submitted
3. The user presses the browser back button
4. The user clicks on red
5. form1 is submitted
6. The user presses the browser back button
7. The user clicks on red
8. nothing happens, since onChange did not detect a "change".

In other words, how do you click on red twice?

Any workarounds on how to do a refresh or something to get around this
above scenario
are highly appreciated!

--- Entfred
 
B

bobzimuta

Does anyone know how to automatically make a web page do a refresh when
the web
page loads? This would prevent the user from having to do the refresh,
themselves.

An example select box would be

<select name="colors" onChange="form1.submit();">
<option value="red">red</option><option
value="blue">blue</option><option value="green">green</option><option
value="purple">purple</option>
</select>

A typical scenario:

1. The user clicks on blue
2. form1 is submitted
3. The user presses the browser back button
4. The user clicks on red
5. form1 is submitted
6. The user presses the browser back button
7. The user clicks on red
8. nothing happens, since onChange did not detect a "change".

In other words, how do you click on red twice?

As a matter of consideration to limited access users (keyboard only)
it's not advised to submit forms when a select element is cycled. They
will always be forced to submit on the second selection. Rather, it is
better to accompany a submit button with the select. That would solve
your problem, as well.
 
R

RobG

I was experimenting with trying to select the same item in a select box
twice in a row
and found out that you need to do a refresh (view - refresh) in
Internet Explorer. This is
so you can click on the same item twice "in a row" to select it.

That approach has serious usability issues as described by bobzimuta.
It is generally a bad idea to use onchange with a select for anything,
or to use onchange on any form control to submit a form.

However, to address the other parts of your question...

Does anyone know how to automatically make a web page do a refresh when
the web
page loads? This would prevent the user from having to do the refresh,
themselves.

You can use window.onload to reset the form.

An example select box would be

<select name="colors" onChange="form1.submit();">

Using the form name this way is not a good idea. If the select is a
control of form1, use:

<select ... onchange="this.form.submit();">

Otherwise use:

<select ... onchange="document.forms['form1'].submit();">


The way you have used it 'works', but it is easy to break.

<option value="red">red</option><option
value="blue">blue</option><option value="green">green</option><option
value="purple">purple</option>
</select>

A typical scenario:

1. The user clicks on blue

Given that red is the first option (and probably the default selected),
selecting it won't fire the onchange handler. Given your scenario, the
first option must be blank or other invalid selection to force the user
to change it and fire the onchange handler. As a result, you can't
have a useful default selection, users *must* change the selection. If
you allow the user to select an option, then submit the form, they can
choose any value and you can set a useful default.
2. form1 is submitted

If they are using keyboard navigation, IE will submit the form as soon
as they navigate up or down using a cursor key. onchange is supposed
to fire when the control loses focus, IE does it prematurely in this
case.

[...]
--- Entfred

The correct way to add a signature is to have two dashes, a space and a
return on a line by themselves. That allows news readers to
automatically trim the signature when quoting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top