473,508 Members | 2,403 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing drop-down field to text field.

ehm
I am working on creating an editable grid (for use in adding,
deleting, and editing rows back to an Oracle database). I have a JSP
that posts back to a servlet, which in turns posts to a WebLogic SFSB
and, from there, to the database.

On the front end, all cells appear as text fields. However, for
certain cells, when the user clicks on the cell, the text field turns
into a drop-down field (i.e. Select object), defaulting to the value
in the text field (unless the field is blank, in which case the
drop-down defaults to the first entry in the drop-down). Once the
user has selected a new entry, the drop-down then turns back into a
text field.

The problem that I am running into is that if the user simply clicks
on a blank field (which then turns into a drop-down), but does not
select anything (i.e. simply uses the default displayed entry), the
drop-down does not turn back into a text field. This causes problems
back in my servlet when I try to retrieve the value, since a text
field's value is actual text, whereas the select object's value is
something entirely different (in my case, I cannot make the displayed
text and value the same).

I have tried using "onBlur", "onClick", etc., but none of those seem
to work. Instead, I am using "onChange", which (obviously) only works
if the user has scrolled through the drop-down and selected a new
entry.

Any suggestions on how to make this work?

As an alternative solution, I have looked at changing all drop-down
fields to text fields once the user hits the "Save" button. I can
retrieve all drop-down fields by using the following:

document.getElementsByTagName("select");

I would like to then use the "innerHTML" logic to change the
drop-down to a text field. The "getElementsByTagName" retrieves the
appropriate cell, but using "innerHTML" on the retrieved object only
clears the drop-down entries, not the entire contents of the cell. Is
there some way that, given a field name, I can retrieve a cell's ID,
i.e. suppose I have the following:

<TD id="grid1Row1Col2"><INPUT CLASS="cell2D" type="text" size="40"
name="TypeTextField1" value="" onFocus="changeToDropDownGrid1(1, 2,
this, 'Type')></TD>

If I know the name "TypeTextField1", is there a way to navigate back
and get the ID of the cell ("grid1Row1Col2")?

Any help on either issue would be greatly appreciated. Thanks.
Jul 20 '05 #1
2 11013


ehm wrote:
I am working on creating an editable grid (for use in adding,
deleting, and editing rows back to an Oracle database). I have a JSP
that posts back to a servlet, which in turns posts to a WebLogic SFSB
and, from there, to the database.

On the front end, all cells appear as text fields. However, for
certain cells, when the user clicks on the cell, the text field turns
into a drop-down field (i.e. Select object), defaulting to the value
in the text field (unless the field is blank, in which case the
drop-down defaults to the first entry in the drop-down). Once the
user has selected a new entry, the drop-down then turns back into a
text field.

The problem that I am running into is that if the user simply clicks
on a blank field (which then turns into a drop-down), but does not
select anything (i.e. simply uses the default displayed entry), the
drop-down does not turn back into a text field. This causes problems
back in my servlet when I try to retrieve the value, since a text
field's value is actual text, whereas the select object's value is
something entirely different (in my case, I cannot make the displayed
text and value the same).

I have tried using "onBlur", "onClick", etc., but none of those seem
to work. Instead, I am using "onChange", which (obviously) only works
if the user has scrolled through the drop-down and selected a new
entry.

Any suggestions on how to make this work?

As an alternative solution, I have looked at changing all drop-down
fields to text fields once the user hits the "Save" button. I can
retrieve all drop-down fields by using the following:

document.getElementsByTagName("select");

I would like to then use the "innerHTML" logic to change the
drop-down to a text field. The "getElementsByTagName" retrieves the
appropriate cell, but using "innerHTML" on the retrieved object only
clears the drop-down entries, not the entire contents of the cell. Is
there some way that, given a field name, I can retrieve a cell's ID,
i.e. suppose I have the following:

<TD id="grid1Row1Col2"><INPUT CLASS="cell2D" type="text" size="40"
name="TypeTextField1" value="" onFocus="changeToDropDownGrid1(1, 2,
this, 'Type')></TD>

If I know the name "TypeTextField1", is there a way to navigate back
and get the ID of the cell ("grid1Row1Col2")?


There is parentElement property in IE4+ and a parentNode property in
IE5+, Netscape 6+ and other W3C DOM compatible browsers. That property
allows "navigating back".

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
ehm
Martin - thanks for the input. That solved one of my bigger problems.

Now, a follow-up question for you (or anyone else).

On my HTML page all cells appear as text fields. However, for
certain cells, when the user clicks on the cell, the text field turns
into a drop-down field (i.e. Select object), defaulting to the value
in the text field (unless the field is blank, in which case the
drop-down defaults to the first entry in the drop-down). Once the
user has selected a new entry, the drop-down then turns back into a
text field.

Some of the feedback that I have gotten is that once the user clicks
on the text field, not only should it change to a SELECT object (which
is currently working fine), but all drop-down elements should appear.
Currently, the user must click on one of these fields three times to
select a new entry: once to change the text field to a drop-down,
another time to display all drop-down options, and a third time to
select the new value. <sarcasm>Apparently, this is putting too much
strain on someone's index finger</sarcasm>, so I am trying to
eliminate one click. Ideally, if the user clicks on one of these text
fields, not only would the field change to a drop-down, but all
elements would be displayed (i.e. simulating the user has clicked the
field a second time).

I have tried to use the "click" method on this SELECT object, but no
luck (i.e. does not force the drop-down list to display). I also
tried the "fireEvent" method (passing in 'onClick'), but also no luck.
The only success I have had is using the "focus" method;
unfortunately, this only places the focus in the field and does not
automatically display all of the select options.

Any suggestions would be appreciated.
Jul 20 '05 #3

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

Similar topics

1
3719
by: Robbie | last post by:
Hi Guys Wonder if you could help me. Basically I produce an accounts package that uses a SQL 2000 DB as the RDBMS. I always instruct users to login as 'sa' and the relevant password when...
4
11112
by: David Wright | last post by:
How can i change the default value of a column? I already have a column named DateOfRental but I want to alter it so that it has default value getdate() Thanks David --...
4
14336
by: Johan Vervloet | last post by:
Does anybody know how I can change the default value for a column? I was trying to remove the default value in order to add the new one afterwards. This is what I tried: alter table...
5
1625
by: WindAndWaves | last post by:
I would like to change the look and feel of a tickbox. Is there anything that I can do???? I want to make it bigger and I want to make it look less like access.... Any help greatly...
10
1610
by: Daniel | last post by:
how to make two references to one string that stay refered to the same string reguardless of the changing value in the string?
1
1411
by: Lars Grøtteland | last post by:
Hello! During drag&drop of items in a CTreeView - how do I replace items on the tree which I drag an item on top of. We can use the example of WindowsXP. In the start menu -> Programs ->...
0
1083
by: Jose C | last post by:
I got the following section of code from: http://msdn.microsoft.com/library/default.aspurl=/library/e nus/cpref/html/frlrfsystemwindowsformscontrolclassdodragdro ptopic.asp Private Sub...
5
2285
by: Sai | last post by:
Hi, We have around 150 databases as case sensitive, and we are planning to change it to case insensitive. Each database has around 180 tables, I have changed the collation on DB, but changing...
9
12476
by: gopi | last post by:
when installing db2, it only asks for installation directory and does not ask where it is going to store data files. how can i change the default directory after installation.
4
3354
by: teddysnips | last post by:
A few weeks ago a client asked me to add a column to a table so I created this script: ALTER TABLE dbo.tblIndividual ADD fldRenewalStatus BIT NOT NULL CONSTRAINT fldRenewalStatus_Default DEFAULT...
0
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5049
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1550
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.