W3C home > Mailing lists > Public > www-html@w3.org > September 1998

What event to trigger to position focus back to a <SELECT>(drop-down list ctrl) control?

From: Amit Rekhi <amit@abinfosys.com>
Date: Mon, 14 Sep 1998 20:05:51 +0530
Message-ID: <005201bddfec$f8ddc000$0101a8c0@server.abinfosys.com>
To: "HTML LIST" <www-html@w3.org>
Hello All.

ENVIRONMENT
Web Browser :- IE 4.01

   Under what event should I trigger a script (attached to a drop down list
box) which would position focus back to it's attached drop down list box in
case the script fails?
   Let me explain :-

SCENARIO

I am constructing a drop down list box as follows :-
.
.
.
<select ID ="TEST" ????="Test(this)"> 
<option value="Test">Test</option>      
<option value="Run">Run</option>
</select>

The script Test(this) is as follows :-
.
.
.
        <SCRIPT LANGUAGE="JSCRIPT">
         function Test(id)
         {
          if(id.value != "Test")
          {
           alert("Select TEST");
           id.focus();
           return false;
          }
         }
</SCRIPT>

OBJECTIVE

* I want that if I do not select "Test" from the drop down list box, then
focus should be retained by the parent <SELECT> element, this should happen
until I select TEST from the drop down list box.

PROBLEM

1) I do not know which event to attach Test(id) to in order to achieve my
objective. I have tried

  * OnChange() but it does not give control back to <SELECT id="TEST".... >
in case the script returns false.
  * OnBlur() and OnClick() , but both seem to go into an endless infinite
loop if Test(id) is attached to them.

QUESTIONS

1)How to achieve my objective of having the <SELECT id="TEST"..> to retain
control, in case the script returns false?
2) What event to attach script Test(id) for it to achieve my objective (for
objective see above)?

Thanks in advance for any answers,

          AMIT
Received on Monday, 14 September 1998 10:30:13 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 27 March 2012 18:15:37 GMT