473,323 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

Automatically click a field

Hi,
can I have a field automatically clicked by calling something like
click()?
I have a dropdown box, one of whose elements is "Others (Please
Specify)". I list the dropdown boxes values alphabetically.
Sometimes, this value happens to be on the top and SELECTED. The problem
is that if this item is selected by clicking on it, in response to
onChange I open a text field (so user can specify the value). If this
field is automatically selected, the text field des not show; I have to
select another value then click on the "Other (please Specify)" to have
the text field visible.

Thanx.
Jul 23 '05 #1
4 1683
Ivo
"Xerxes" wrote
Hi,
can I have a field automatically clicked by calling something like
click()?
Yes. Newer browsers implement that method for a variety of elements as the
references can tellyou.
I have a dropdown box, one of whose elements is "Others (Please
Specify)". I list the dropdown boxes values alphabetically.
Sometimes, this value happens to be on the top and SELECTED. The problem
is that if this item is selected by clicking on it, in response to
onChange I open a text field (so user can specify the value).
The problem is you rely on an onchange while sometimes there is none. Create
a dummy option, with a title text and no value, on top, so that one is
selected when there is none selected.

HTH
Ivo
If this
field is automatically selected, the text field des not show; I have to
select another value then click on the "Other (please Specify)" to have
the text field visible.

Thanx.

Jul 23 '05 #2
Thanks Ivo.
The problem with creating a dummy value is that the values of the
dropdown box are set by querying a database, sorted alphabetically. If I
use something like "Select something...", it might fall somewhere in the
middle of the list of values. Any way I can get around it? Can I assign
an index (of zero) to an option?

<SELECT>
<options are filled in from a database in a php file>
< option index=0 (??)>Make a selection</option>
</select>

Thanks.

"Ivo" <no@thank.you> wrote in message
news:40***********************@news.wanadoo.nl...
"Xerxes" wrote
Hi,
can I have a field automatically clicked by calling something like
click()?
Yes. Newer browsers implement that method for a variety of elements as

the references can tellyou.
I have a dropdown box, one of whose elements is "Others (Please
Specify)". I list the dropdown boxes values alphabetically.
Sometimes, this value happens to be on the top and SELECTED. The problem is that if this item is selected by clicking on it, in response to
onChange I open a text field (so user can specify the value).
The problem is you rely on an onchange while sometimes there is none.

Create a dummy option, with a title text and no value, on top, so that one is
selected when there is none selected.

HTH
Ivo
If this
field is automatically selected, the text field des not show; I have to select another value then click on the "Other (please Specify)" to have the text field visible.

Thanx.


Jul 23 '05 #3
Ivo
"Xerxes" wrote
Thanks Ivo.
The problem with creating a dummy value is that the values of the
dropdown box are set by querying a database, sorted alphabetically. If I
use something like "Select something...", it might fall somewhere in the
middle of the list of values. Any way I can get around it? Can I assign
an index (of zero) to an option?


Silly you! Can't you add the first option after the sorting has taken place?
Like with line no. 2 added to your code below:

1. > <SELECT>
2. <option value="">Look Ma, no sorting.
3. > <options are filled in from a database in a php file>
4. > </select>

If you need to have the options in an PHP array before anything else, have a
look at www.php.net/array_unshift.
HTH
Ivo
Jul 23 '05 #4
Xerxes wrote:
Hi,
can I have a field automatically clicked by calling something like
click()?
I have a dropdown box, one of whose elements is "Others (Please
Specify)". I list the dropdown boxes values alphabetically.
Sometimes, this value happens to be on the top and SELECTED. The problem
is that if this item is selected by clicking on it, in response to
onChange I open a text field (so user can specify the value). If this
field is automatically selected, the text field des not show; I have to
select another value then click on the "Other (please Specify)" to have
the text field visible.

Thanx.


<script type="text/JavaScript">
function replaceOptionWithPrompt(menu,msg){
if(menu.selectedIndex==menu.length-1){
var x=window.prompt(msg,"");
if(x){
menu[menu.length-1]= new Option(x,x);
menu[menu.length-1].selected=true;
}
}
}
</script>

<form>
<select name="jobs" onchange="replaceOptionWithPrompt(this,'Please
supply your job description')">
<option selected>Profession</option>
<option value="doc">Doctor</option>
<option value="atty">Lawyer</option>
<option value="realtor">Real Estate</option>
<option value="other">Other</option>
</select>
</form>

Mick
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: paul b | last post by:
Hello, I have a small problem in PHP an perhaps someone can help me: I have a simple HTML login page with a username and a password field, as well as a submit button, which I have to use for...
4
by: Andy Hutchings | last post by:
Hi everybody - hope you can help out here. I have a form in a database, which is a columnar form from one of the tables in the db - there is a sub-form to the form which is a datasheet view of...
1
by: Curtis | last post by:
I am having a problem with the coding below that someone was trying to help me with in another website. I have been to several websites and hopefully here I can get it resolved. I inherited this...
1
by: marksjy | last post by:
I have a small database with a primary key similar to a social security number (SSN). The tables are tied to the primary table via the SSN-type field with referential integrity. I have a number...
1
by: namanhvu | last post by:
Hi everyone, I'm trying to create a form where the radio button is automatically selected when the input text field beside it is clicked. I know I need to use "onClick" somewhere but I don't...
9
by: Nooby | last post by:
New to Access here. I inherited a db that has the first column as an automatically generated sequential number. I want to bump it up, but for the life of me I can't figure out how to do it. Is...
4
by: JA | last post by:
Not exactly sure how to explain this. I have 4 fields (in access 2000). Category, Catid, Subcat, subcatid. There are 40 categories, and about 1500 subcats. I've added the categories to the...
3
by: perryche | last post by:
All, In excel, when you find a field within a spreadsheet is wrong, and every row needs to be changed, you simply change one cell, copy that cell, and select all the rest of the cell, and paste...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.