• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drop down values

 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am using a drop down with three selections.

<select name="type" onchange="choose(this.options[this.selectedIndex].value)">
<OPTION VALUE="RC">O1</OPTION>
<OPTION VALUE="RS">O2</OPTION>
<OPTION VALUE="RP" >O3</OPTION>
</select>

I want to get the selected values from the drop down before submitting the form.

Any help,

Thanks in advance,

Ananth
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ananth Ram:
I want to get the selected values from the drop down before submitting the form.
Get it where? In JavaScript? it appears that you already know how to do that in your event handler.

On the server? Why would you need it prior to form submission? The answer to that question may have a great effect on the answer.
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

I awant to pick up the value and pass it to servlet, once the form is submitted, but the drop down is not part of the Action form ( I am using Struts). Could you please help me.

Ananth
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the control is inside of the form tag then the name/value pair will post to the servlet and you can get it from the request
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks,

I am not able to get the picture. Could you help me explain more..

Ananth
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It can't get much clearer; if the select element is in the form it will be submitted to the server.

Is it in the form?

Is it getting the value on the server that's what's really giving you an issue?
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks in advance.

The problem is that I want to hold the dropdown selected value in a variable and pass it on to database based on the selection, dropdown is inside a form. The form data is pertaining to one table and the drop down values are to a different table. Is there anyway I can get hold of the values and pass it on to database. The form


function enableSelected() {
document.messagesForm.selectedEmails.disabled = false;
}

<html:form action="actionProcess.do?method=addValue" method="post" onsubmit="enableSelected();">

<select name="type" >
<OPTION VALUE="RC">O1</OPTION>
<OPTION VALUE="RS">O2</OPTION>
</select>

Thanks,
Karthik
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
submit the form in your method. Then follow our earlier directions.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is all something that you need to do on the server side. Since you are using Struts, I've moveed this to the appropriate forum.
 
Ananth Ram
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.

I resolved the issue, by adding the drop down as property in form. It also helps me to validate the drop down.

Thanks for the help.

Ananth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic