Link to home
Start Free TrialLog in
Avatar of eldoz12
eldoz12

asked on

missing hidden field

Hello expert ,
I have hidden field in a jsp
<input type="hidden" name="actionRequired"/>

I set the value in a javascript as below

if(validateSearchCriteria())
          {
                 alert("passed validation criteria");
               if(document.forms["limsRecordAdvancedSearchForm"].elements["useAltSearch"].checked == true)                            
                    document.forms["limsRecordAdvancedSearchForm"].elements["actionRequired"].value = "ALTERNATESEARCH";
               /*else if(trimString(document.forms["limsRecordAdvancedSearchForm"].elements["recordNo"].value) != "")
                    document.forms["limsRecordAdvancedSearchForm"].elements["actionRequired"].value = "SINGLERECORD";*/
               else                                  
                    document.forms["limsRecordAdvancedSearchForm"].elements["actionRequired"].value ="ADVANCEDSEARCH";
                    alert("setting actionRequired as" +actionRequired");
                    document.forms["limsRecordAdvancedSearchForm"].submit();
          }


The filed needs to set itself to ="ADVANCEDSEARCH" which it does , I check it with alert statment ,
but in the action class when i try to read the parameter

actionRequired = request.getParameter("actionRequired");
is get a empty string .
Why would something like this happen , where could i be lossing the data for the hidden field .

plz advice
Avatar of fargo
fargo

would you mind posting your complete form ?
Hi
Yes, post your complete form.

1. May be you have not put your "hidden field" in your "form".
2. Try using hidden text box
    <input type="text" name="actionRequired" style="visibility:hidden"/>

I think it may help.

By Nab
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it's the fact that your javascript code is wrong that's giving you the problems I feel...
Just to debug:
Try to make hidden field as text field:

<input type="text" name="actionRequired"/>

then when you submit see what value you are getting in there.

If it is holding the value then your form class, or action class is malfunctioning.