Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-15-2008, 09:16 AM
Member
 
Join Date: May 2008
Posts: 14
hussainzim is on a distinguished road
Add data to combobox in page load
i want to add data to a combo box dynamically in a page load in jsp.currently i hav got da data from a servlet to the jsp.thank u in advance...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-15-2008, 10:17 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 175
Eku is on a distinguished road
HTML are not that Dynamic so you must be Creative to make it look Dynamic. YOu can use Javascript or Ajax to do it. But i dont know that yet. So here is my solution using only JSP and Servlet.

In your Servlet you should have this code
wherein OptionFromServlet is a String that you will be passing from Servlet to the JSP
Code:
<select Type="ComboBox" name="drop"> <%=OptionFromServlet> </select>
In your Servlet you have this
Code:
String Temp[] = {"One","Two","Three"}; //here is where your list is String OptionToJSP=null; Int ctr = Temp.length(); for(int i=0; i<ctr; i++){ OptionToJSP += "<OPTION>" + Temp[i] + "</OPTION>"; } OptionToJSP = OptionToJSP.substring(4); //Then Return OptionToJSP to the JSP. . .
The only problem with this is when the page is loaded the combox is null. You have to put a refresh, to Load the data from the Servlet to the JSP. =P

I Hope that Helps
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 05-15-2008, 11:03 AM
Member
 
Join Date: May 2008
Posts: 14
hussainzim is on a distinguished road
i want to load data into the combo box without clicking any button.daata should be there when the page is loaded.hw can i do that??
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 05-15-2008, 11:25 AM
Eku Eku is offline
Senior Member
 
Join Date: May 2008
Location: Makati, Philippines
Posts: 175
Eku is on a distinguished road
Im still a noob in J2EE, lets wait for the experts to answer your question. =)
__________________
Mind only knows what lies near the heart, it alone sees the depth of the soul.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 05-15-2008, 01:26 PM
rjuyal's Avatar
Senior Member
 
Join Date: Mar 2008
Location: Delhi, India
Posts: 160
rjuyal is on a distinguished road
in your jSP
Code:
<script> window.onLoad = init(); function init(){ fill_my_combo_box( myComboBoxID, listOrMapOfValuesToPopulate); } </script>
is that ookay, or should i write the code for fill_my_combo_box as well
__________________
Newton said Gravitaion, Rakesh says Earth Sucks
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 05-15-2008, 01:57 PM
Member
 
Join Date: May 2008
Posts: 14
hussainzim is on a distinguished road
hey..im kinda new to jsp and stuff so can u write the code for fill_my_combo_box as well..plss
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Adding ComboBox impact New To Java 2 05-02-2008 09:43 PM
How to display Tabuler Data in J2EE application on jsp page AMATYA-CHANAKYA Advanced Java 2 04-23-2008 06:54 PM
HashMap and ComboBox banie AWT / Swing 2 03-26-2008 12:58 AM
how to load a servlet on index.jsp page... sujithc34 Java Servlet 1 01-19-2008 01:28 AM
ComboBox with database options Goldy Advanced Java 0 12-01-2007 10:43 PM


All times are GMT +3. The time now is 10:53 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org