• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting the contents of an option tag  RSS feed

 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<select name="heros">
<option value="bruce wayne">Batman</option>

In a servlet I can get the value like this:

String alias = request.getParameter("heros");

But is there a way to get the option contents? A string that would contains Batman.

Thanks,

Luke
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. Only the value is submitted as part of the request.
[ November 01, 2004: Message edited by: Bear Bibeault ]
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh well. Thanks for the quick response.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No prob. What are you really trying to do? (Or was it just an academic question?)
 
Luke Shannon
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what I was trying to do (hopefully it is not too confusing).

I am creating a list of contacts from a DB.

The value of the tag is the contactID (primary key from the DB) and content of the tag in the actual name of the client.

Previously, I had their actual name in both the value and contents of the option.

If you selected a contact to modify their profile I could pass the name through the servlet context from the current form to the modification form page. Thus you had a nice header at the top of the page:

You Are Now Modifying: <some contacts name> <-- option value from select form

But since I built this the DB got normalized.

The contact table got broken into several tables each with primary keys.

So I decided when I looked up the list of names to put in the option tags of the drop down I would create a TreeMap instead of an ArrayList containing the contactID and actual name.

But than I ended up with:

You Are Modifying: <some guys contactID> <-- option value has primary key

So, last night in my over tired state I thought all I need to do is get the content of the tag and than I will have the name. So silly.

After some sleep I realized that was unnecessary. I am already creating a contactBean to populate the contact's existing information into a form.

Previously, I was passing the contact name into a "bean generating class" to create and populate my contact bean.

But I ran into contacts with the same name (depending on who was in the result set first the bean could end up contain data from a different contact).

Thus I normalized the DB and gave tables primary keys. Than I could reference the contact in the DB I wanted with the ID and get the correct data.

It was just a matter of setting and getting the name value in the bean by passing in the contactID to look this information up. Than the passing this bean through the servlet context to the modification form.

Than I could do this:

You are now modifying: <contactBean.contactName>

Now I am on the right track.

This a prime example of what happens when you try and code without enough sleep.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!