Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > select box - using refresh to select same item twice

Reply
Thread Tools

select box - using refresh to select same item twice

 
 
entfred@hotmail.com
Guest
Posts: n/a
 
      07-25-2006
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

 
Reply With Quote
 
 
 
 
bobzimuta
Guest
Posts: n/a
 
      07-25-2006
(E-Mail Removed) wrote:
> 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.

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      07-25-2006
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> 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.


--
Rob.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bug with nested repeaters. Item events are called twice per item =?Utf-8?B?SmFtZXMgR2V1cnRz?= ASP .Net 4 03-28-2007 01:46 AM
twice(twice(x)) Kiuhnm C++ 2 04-01-2006 04:41 PM
detecting same item selected again in a dropdown box Andy Fish Javascript 1 06-15-2005 11:39 AM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM
Same user twice in the same aspx.. Rajesh.V ASP .Net Web Controls 0 08-06-2003 06:19 PM



Advertisments