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
eldoz12Asked:
Who is Participating?
 
TimYatesCommented:
>> 2. Try using hidden text box

Why?

I'd give the hidden element an id:

    <input type="hidden" id="AR" name="actionRequired"/>

You are also missing { and } round the if and else blocks...

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

Tim
0
 
fargoCommented:
would you mind posting your complete form ?
0
 
nabsolCommented:
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
0
 
TimYatesCommented:
it's the fact that your javascript code is wrong that's giving you the problems I feel...
0
 
raj3060Commented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.