0

In my jsp page I have a javascript function for a button click.In that I need to pass some values to next jsp page.I can able to pass two values as a parameter but while giving three values its not working.Not working means control is not going next page when click on button.

This one works fine

window.location.assign("gt_Iba2?value="+uri+"&len="+<%=height%>);

This is not working

window.location.assign("gt_Iba2?value="+uri+"&len="+<%=height%>+"&SelectedValue="+<%=typeNameToPass%>);

EDIT

typeNameToPass is a string value i'm getting from previous jsp page.

String typeNameToPass =request.getParameter("value");

My javascript function

<SCRIPT LANGUAGE="JavaScript">
                function gt2()
                {
                var pqr="100";
                var arr=new Array();
                var x=<%=height%>;
                var attstr=null;
            for(var t=0;t<x;t++)
            {
            var a="inputText"+t;

                var e=document.getElementById(a);
                var val= e.value;
                if(val.indexOf(",") !== -1){
                alert("Legal value Constraint can't allow comma");
                return;
                }
                arr[t]=val;

                if(t==0)
                {
                attstr=arr[t]+",";
                }

                if((t!=x)&&(t!=0))
                {
                if(t==x-1)
                {
                attstr+=arr[t];
                }
                else
                {
                attstr+=arr[t]+",";
                }

                }
          }
            var uri=encodeURIComponent(attstr);
            window.location.assign("gt_Iba2?value="+uri+"&len="+<%=height%>+"&SelectedValue="+<%=typeNameToPass%>);

I don't know what's wrong here.Any ideas would be much helpful

6
  • 1
    Maybe <%=typeNameToPass%> contains quotes? Commented Oct 28, 2013 at 6:54
  • 2
    What are the values of your height and typeNameToPass? Maybe they form a wrong js string. Commented Oct 28, 2013 at 6:54
  • @MatteoTassinari No they are string only.Actually height is an integer value Commented Oct 28, 2013 at 6:55
  • 1
    Please show the actual values which produce an error. Commented Oct 28, 2013 at 6:57
  • Can you post the values that <%=typeNameToPass%> can take? Commented Oct 28, 2013 at 6:57

1 Answer 1

1

Try that:

window.location.assign("gt_Iba2?value="+uri+"&len=<%=height%>&SelectedValue=<%=typeNameToPass%>");

Your code works for height, probably because it is number. Then you will get in JS something like "[...]&len="+80, but if typeNameToPass is a string value you will get "[...]&len="+80+"&SelectedValue="+someString - unless someString is a variable, you will get error.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.