Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 29th, 2006, 08:43 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default JSP combo box

Code:
<select NAME="Tour" onchange="frmDisplay.submit()">
            <% String temp2 = "";
               while(rsTour.next()){ 
                    temp2 = rsTour.getString(1);
                    if (temp2 == tour) { %>           
                        <option selected><%=temp2 %></option>
            <%     }else{ %>
                        <option><%=temp2 %></option>         
            <%     } } %>
            <option><%=tour %></option>
</select>
this is my code for a combo box in my html form.
However, I want the combo box show me the value i selected before submit. But, it will only show me the default first value.
For example, I choose "BBB", but after the event on change, and come back to this page, it will show "AAA" which is the first choice.
Is there anyway to show my selection as the default ?

thank you

Reply With Quote
  #2 (permalink)  
Old December 15th, 2006, 07:27 AM
Registered User
 
Join Date: Dec 2006
Location: Delhi, Delhi, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For Solving ur problem just place ur if condition in side the option box. and in between of option write selected. then hope when u change valus ur selected value vl not change.
like:---

<select NAME="Tour" onchange="frmDisplay.submit()">
            <% String temp2 = "";
               while(rsTour.next()){
                    temp2 = rsTour.getString(1);
                    %>
                        <option <%if (temp2 == tour) {%>selected <%}%>><%=temp2 %></option>
                        <option><%=temp2 %></option>
            <% } %>
            <option><%=tour %></option>
</select>


this is my code for a combo box in my html form.
However, I want the combo box show me the value i selected before submit. But, it will only show me the default first value.
For example, I choose "BBB", but after the event on change, and come back to this page, it will show "AAA" which is the first choice.
Is there anyway to show my selection as the default ?


Sachin Mangla
Software Developer
Delhi
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate a text box from a combo box value dnf999 Access VBA 7 February 6th, 2012 02:24 PM
Combo box to display items from parent combo box Gini Visual Studio 2008 0 June 18th, 2008 12:30 AM
Count in combo box(display results in text box) mboyisis Access 4 April 4th, 2008 07:08 AM
Combo box choice creating filtered combo box stevensj5 Access 11 September 13th, 2007 11:33 AM
Populate List Box by Combo Box Selection mmcdonal Access 2 June 15th, 2004 12:08 PM



All times are GMT -4. The time now is 01:41 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.