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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fargoCommented:
would you mind posting your complete form ?
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
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TimYatesCommented:
it's the fact that your javascript code is wrong that's giving you the problems I feel...
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.