Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1195
  • Last Modified:

hidden fields in jsp

<form method="post">

<select name ="getselected" id="getselected">
<option>fox</option>
<option>fox2</option>
<option>fox3</option>
</selected>

<input type="hidden" name="hidden" value="<%=getselected%>">

</form>




on server side

String selectedvalue = (String)request.getParameter("hidden");



when i use hidden field in jsp it showed me an error

Multiple annotations found at this line:
      - Tag (input) should be an empty-
       element tag.
      - getselected cannot be resolved to a
       variable
0
shragi
Asked:
shragi
  • 2
2 Solutions
 
Sathish David Kumar NCommented:
while loading the page <%=getselected%> is null so that only its give error more over you cant get that value directly .

try this

String selectedvalue = (String)request.getParameter("getselected");
0
 
rrzCommented:
I have been reading your other questions. This a javascript question.  
If your hidden field in your form is
<input type="hidden" name="fileLocation" value="not yet">
and you have
 <select name="selectedFile" >
...
</select>
and you have
<input class="button" value="Submit" type="button" onclick="performAction2()" />
then your script will be  
<script language="JavaScript" type="text/javascript">
   function performAction2() {
       document.forms[0].fileLocation.value = 
              document.forms[0].selectedFile.options[document.forms[0].selectedFile.selectedIndex].value;
       document.forms[0].submit();
   }
</script>

Open in new window

0
 
Sathish David Kumar NCommented:
if u want to set the values dynamically then u can use JSTL tag

Before loading the page jsut set the hiddenValue as blank

request.setAttribute("hiddenValue","");
In jsp
<input type="hidden" name="hiddenV" value="${hiddenValue}">
while changing the dropdown call some java script
set the value in java script function
document.forms[0].hiddenV.value=document.forms[0].getselected.value
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now