0

i want selected value in input text field in jsp how to do please help? I am new with jsp.

<select class="leavetype" name="leavetype">
    <option value="10">CL</option>
    <option value="7">ML</option>
    <option value="12">SL</option>
    <option value="20">EL/PL</option>
    <option value="5">CPL</option>
  </select>
  <input type="text" name="leave"/>
Monika Rawat
  • 13
  • 1
  • 7
  • Your question is unclear, but to get the selected value using Javascript refer to https://stackoverflow.com/questions/1085801/get-selected-value-in-dropdown-list-using-javascript **or** do you mean when posted to a servlet? – Scary Wombat Apr 17 '18 at 07:24
  • when you submit the form, the value of the selected option will be passed to your controller :) simple as that. What backend are you using? pure servlets or a framework? – Jack Flamp Apr 17 '18 at 07:29
  • You are using normal html tag , so i guess you are also using javascript. So try to look getting and settting values via js. – parlad Apr 17 '18 at 15:22

2 Answers2

1

See this video:- https://www.youtube.com/watch?v=89rRD04QZE4

Hope so it will help you.

In jsp page you may write. ${param.leavetype}.

Mehadi Hassan
  • 1,160
  • 1
  • 13
  • 33
0

You can achieve through javascript by using onChange function. Within in function need to do like this document.getElementById ("leave").value = data.value;

Refer this Answer

Lucifer
  • 784
  • 2
  • 7
  • 20