Html Listbox Question

S

Sunny

Hi,

How I can move to the first value in Listbox.
I have a listbox that has some values.
When I select any value from it. It opens a div with the info about
that value.
But when I click on close Button of that div & div goes away. and I
select the same value again.
The div dont appear.
Is there anyway, I can make the listbox value to show the first entry,
when I click on Close div button.
 
D

David Mark

Hi,

How I can move to the first value in Listbox.
Pardon?

I have a listbox that has some values.
Okay.

When I select any value from it. It opens a div with the info about
that value.

Have to take your word for it. You click, it "opens a div."
But when I click on close Button of that div & div goes away. and I

Where is this div (and the code that goes with it?)
select the same value again.
The div dont appear.
Okay.

Is there anyway, I can make the listbox value to show the first entry,
when I click on Close div button.

Is there any way you could post some (if not all) of the offending
code.
 
S

Sunny

Have to take your word for it. You click, it "opens a div."


Where is this div (and the code that goes with it?)


Is there any way you could post some (if not all) of the offending
code.

Sorry for that:
Here is the code:
function OnChange(dropdown)
{

myindex =
dropdown.selectedIndex //This
assigns the combobox index to a variable.
var SelValue =
dropdown.options[myindex].value //This
assigns the combobox index value to a variable.
if (document.getElementById("detailsPopup").style.display ==
"none") //If the detailsPopup is not showing on the map show it.
{
document.getElementById("detailsPopup").style.display = "block";
}
if (document.getElementById("detailsPopup2").style.display ==
"none")
{
document.getElementById("detailsPopup2").style.display = "block";
}
}

This is a function to close the div.

function closeDiv()
{
if (document.getElementById("detailsPopup2").style.display == "block")
{
document.getElementById("detailsPopup2").style.display = "none";
}
if (document.getElementById("detailsPopup").style.display == "block")
{
document.getElementById("detailsPopup").style.display = "none";
}
}
 
S

sasuke

Have to take your word for it.  You click, it "opens a div."
Where is this div (and the code that goes with it?)
Is there any way you could post some (if not all) of the offending
code.

Sorry for that:
Here is the code:
function OnChange(dropdown)
{

    myindex  =
dropdown.selectedIndex                                   //This
assigns the combobox index to a variable.
    var SelValue =
dropdown.options[myindex].value                          //This
assigns the combobox index value to a variable.
                                 if (document.getElementById("detailsPopup").style.display ==
"none")  //If the detailsPopup is not showing on the map show it.
                                 {
                                 document.getElementById("detailsPopup").style.display = "block";
                                 }
         if (document.getElementById("detailsPopup2").style.display ==
"none")
                                 {
                                 document.getElementById("detailsPopup2").style.display = "block";
                                 }

}

This is a function to close the div.

function closeDiv()
{
if (document.getElementById("detailsPopup2").style.display == "block")
                         {
        document.getElementById("detailsPopup2").style.display = "none";
                 }
if (document.getElementById("detailsPopup").style.display == "block")
                         {
                                 document.getElementById("detailsPopup").style.display = "none";
                 }
        }

Honor the 80 char limit along with replacing tabs with spaces when
posting code. Posting something along the lines of a SSCCE <http://
mindprod.com/jgloss/sscce.html> would help the others in pinpointing
the issue with minimalistic effort.

As for your issue, just invoke the function which you would invoke
when a list item is clicked with the argument as the value of the list
item[assuming you have designed your application in a modular way with
separate function to handle the show/hide of DIV based on the value
passed].

/sasuke
 
T

Thomas 'PointedEars' Lahn

Sunny said:
Is there any way you could post some (if not all) of the offending ^^^^^^^^^
code.
^^^^
Sorry for that:
Here is the code:
function OnChange(dropdown)
{

myindex =
dropdown.selectedIndex //This
assigns the combobox index to a variable.
var SelValue =
dropdown.options[myindex].value //This
assigns the combobox index value to a variable.
if (document.getElementById("detailsPopup").style.display ==
[...]

That's *offending* code for sure.


SCNR

PointedEars


P.S.: <http://jibbering.com/faq/#FAQ2_3>
 
D

David Mark

Have to take your word for it.  You click, it "opens a div."
Where is this div (and the code that goes with it?)
Is there any way you could post some (if not all) of the offending
code.

Sorry for that:
Here is the code:
function OnChange(dropdown)
{

    myindex  =
dropdown.selectedIndex                                   //This
assigns the combobox index to a variable.
    var SelValue =
dropdown.options[myindex].value                          //This
assigns the combobox index value to a variable.
                                 if (document.getElementById("detailsPopup").style.display ==
"none")  //If the detailsPopup is not showing on the map show it.
                                 {
                                 document.getElementById("detailsPopup").style.display = "block";
                                 }
         if (document.getElementById("detailsPopup2").style.display ==
"none")
                                 {
                                 document.getElementById("detailsPopup2").style.display = "block";
                                 }

}

This is a function to close the div.

function closeDiv()
{
if (document.getElementById("detailsPopup2").style.display == "block")
                         {
        document.getElementById("detailsPopup2").style.display = "none";
                 }
if (document.getElementById("detailsPopup").style.display == "block")
                         {
                                 document.getElementById("detailsPopup").style.display = "none";
                 }
        }

If I understand your original post (not sure I do), it looks to me
like you have made some bad design decisions. I would add a "Details"
button to display the DIV. The change event is for updating the
states of other inputs on the form. It isn't for validation,
navigation or pop-up messages.

And never do this:

document.getElementById("detailsPopup").style.display = "none"

Always test the return value of gEBID before usage. Yes, if you
substitute "$" for "document.getElementById", you have the archetypal
pattern used by code-re-arrangers (e.g. users of Prototype, jQuery,
etc.) That confirms it as poison.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top