Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox DTC value referenced on client-side

Status
Not open for further replies.

dustin96

IS-IT--Management
Jan 17, 2002
2
US
I am using a form that consists of both server-side DTC's as well as client-side entry fields. When the form is submitted, I am trying to make a javascript window pop up with the information that was entered as a confirmation window. The difficulty I am having is retreving the value that is selected in the listbox dtc's since they are server-side objects. Is there any way to reference that selected object or am I going to have to do something using multiple pages? I'm sure this is a relatively simple problem but I am new to the development game. Thanks in advance for the help!
 

Hi,
I know how to reference DTC textbox on client side.
It's

document.thisForm.MyTextbox.value

You could try the same with Listbox

document.thisForm.MyListbox.value

"Defeat is not the worst of failures. Not to have tried is the true failure."
-George E. Woodberry
 
The current item in a list is indicated by:

document.thisForm.lstList.selectedIndex

And the text or value of a perticular list entry:

document.thisForm.lstList.option(index).text
document.thisForm.lstList.option(index).value

Put these together to get:

with document.thisForm.lstList {
var selectedValue = option(selectedIndex).value;
var selectedText = option(selectedIndex).text;
if (selectedText == '<Please Select An Option>') {
alert ('Pick somthing from the list will you!');
...
}
}

or similar!
(Content Management)
 
document.thisForm.lstList.selectedIndex works...however when I try to use the other two options, I get the following error: Object doesn't support this property or method. Perhaps my syntax is wrong:

document.thisForm.lstList.option(0).text;

This should report the text for entry 0 correct? This just reports the above error. What am I doing wrong? Thanks again for the help!
 
oops, yes. try options.

The
document.form.listbox.value
value returns the selected 'value' - which is sometimes good enough for validation. You only need this longer syntax to display the text of the selected item - or to do other things.

If you add an HTML SELECT clause (or run your page, do View Source, and copy the SELECT for your combo/list, and paste this into your page) then you will notice that your Client-Side script will include it in the pop-up object helper list in the editor - type document.thisForm. and your combo/list is included there. Select your combo/list and loads of methods and properties will then be listed (including 'options'). Its not perfect, but it helps! (Content Management)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top