Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Drop Down

Posted on 2002-05-19
8
Medium Priority
?
228 Views
Last Modified: 2010-04-01
I would like to allow the user to select an option from a drop down and have it cause the information displayed on the page to change without have to have them press any submit buttons.  Is this possible.  I tried using onchange and the other on´s but got know where with it.

Thanks
0
Comment
Question by:menreeq
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 6

Expert Comment

by:kotan
ID: 7020671
Try this,

<script>
function goTo(val) {
 location.href="yourJspPage.jsp?parameter="+val;
}
</script>

In table:
<td>
<select name="selectOptions" onchange="goTo(this.options[this.selectedIndex].value)">
             <option value="option 1">option1</option>
             <option value="option 2">option2</option>
             <option value="option 3">option 3</option>
           </select>
            &nbsp; View Option &nbsp;
</td>
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 300 total points
ID: 7021652
if you want to change text without reloading try:

<SCRIPT LANGUAGE="JavaScript">
function updateText(optionValue) {
    text = "This is your initial display.'"
    if (optionValue == 1) {
         text = "Text if 1 is selected."
    }
    else if (optionValue == 2) {
         text = "Text if 2 is selected."
    }
    else if (optionValue == 2) {
         text = "Text if 3 is selected."
    }

    document.all("MyID1").innerText = text;
}
</SCRIPT>

<P ID="MyID1">This is your initial display.</P>

<FORM><select name="updateText" onchange="updateText(this.options[this.selectedIndex].value)">
            <option value=1>option1</option>
            <option value=2>option2</option>
            <option value=3>option 3</option>
          </select>
</FORM>


HTH,
CJ
0
 

Author Comment

by:menreeq
ID: 7021771
Great, but I am pulling the different options from a bean...so i want to refresh the page and call the options from the bean how would i go about that? can i insert the call to the bean from within the script tags?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 19

Expert Comment

by:cheekycj
ID: 7021787
Like this:

I am assuming your bean is a collection or an arraylist:
<select name="selectOptions" onchange="goTo(this.options[this.selectedIndex].value)">
   <% for (int i = 0; i < yourBean.size(); i++) {
            String value = (String) yourBean.get(i); %>
            <option value="<%=value%>">Option <%i+1%></option>
   <% } %>
          </select>
0
 

Author Comment

by:menreeq
ID: 7036883
I have it to the point that i have a submit query button that calls my bean and populates the fields corresponding to the selection selected.  Using your suggestions i made a javascript function that does a click() for that submit querry button, i also have it as style:display-none to make the button not appear.  It works but i don´t like the fact that the page has to reload since the button submits the information to a servlet that then calls the bean....should i be able to change the information in the input boxes without having to submit the form(i am using input boxes because i want the user to be able to edit the data)?  If so how?  
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7037537
you would have to have your servlet retrieve all the info and store it in JavaScript vars to be able to  update the page without reloading.
0
 

Expert Comment

by:mark_at_serialmonkey
ID: 7038339
If you didn't want the whole page to refresh you could write a servlet that just returns the parameters from your bean and hide it in a hidden frame. Then use DHTML to update the options. You may have trouble working this with IE and Netscape though (but the solution given by cheekycj above wouldn't work in Netscape either since it doesn't support innerText calls (at least V4 Netscape doesn't anyway as far as I know)
0
 
LVL 19

Expert Comment

by:cheekycj
ID: 7044583
Glad I could help, Thanx for the "A"
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The online market is growing at an unprecedented rate and retail eCommerce sales are expected to reach $4 trillion by 2020. Yet, the profit is not just there for the taking because you have to set yourself apart from the competition.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

664 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question