I have try follows two method: function goURL(tmp){ document.forms[0].action=eval("/Log/log.do?action="+tmp); alert(eval("/Log/log.do?action="+tmp)); document.forms[0].submit(); }
and function goURL(tmp){ var newAct = "/Log/log.do?action="+tmp; document.forms[0].action = newAct; alert(newAct) document.forms[0].submit(); } I find Javasript can alert right value,such as /Log/log.do?action=3 but I find Javascript don't redirect any page,my action don't be called! Why? On 2/20/06, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: > > A few things here, > > 1) I think you need build the action like the following; > > document.forms[0].action=eval("/Log/log.do?action="+tmp); > > or do it in two steps: > > var newAct = "/Log/log.do?action="+tmp; > document.forms[0].action = newAct; > > 2) how are you checking the action parameter in your Action class, > checking > action=First or action=0? > the above will give you action=0, or action=1 etc, but not action=First, > action=Second. The reason I ask the question is b/c you mentioned > <html:link > page="/log.do?action=First">First Page</html:link> works for you, you are > passing a "First" to the action in this case. > > > Saul > > ----- Original Message ----- > From: "red phoenix" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" <user@struts.apache.org> > Sent: Sunday, February 19, 2006 10:12 PM > Subject: Re: why my page can't redirect under Struts with Javascript? > > > My web context is Log,so I add prefix before,like follows: > > document.forms[0].action="/Log/log.do?action="+eval(tmp); > > but when I change the value of <html:select>,it still can't redirect,I am > puzzled it for several days.I don't know why it don't redirect!!! > > I want to use above code to make a pagination program,the <html:select> > shows all pages,such as 1st Page,2nd Page,3rd Page and so on,when selected > one of items of <html:select>,it will call Javascript and redirect page to > a > action. > > Anybody can give me some adivce? > > > > On 2/20/06, Saul Qunming Yuan <[EMAIL PROTECTED]> wrote: > > > > For the following: > > > > document.forms[0].action="/log.do?action="+eval(tmp); > > > > You'll need to prefix "/log.do" with your web context. Or you can use: > > <html:rewrite page='/log.do' /> in place of /log.do above. > > > > hope it helps. > > Saul > > > > > > ----- Original Message ----- > > From: "red phoenix" <[EMAIL PROTECTED]> > > To: <user@struts.apache.org> > > Sent: Sunday, February 19, 2006 6:48 PM > > Subject: why my page can't redirect under Struts with Javascript? > > > > > > I use Javascript in Struts,like follows: > > > > <script language="JavaScript"> > > function goURL(tmp){ > > alert(tmp); > > document.forms[0].action="/log.do?action="+eval(tmp); > > document.forms[0].submit(); > > } > > </script> > > > > <html:form method="post" action="log.do"> > > <html:link page="/log.do?action=First">First Page</html:link> > > <html:select property="pageID" size="1" onchange="javascript:goURL( > > this.options[this.selectedIndex].value)"> > > <option value="0">First</option> > > <option value="1">Second</option> > > <option value="2">Third</option> > > </html:select> > > </html:form> > > > > when click "First Page",I can redirect my page to log.do page,but when I > > change the value of select,and call goURL,I find my page don't redirect > to > > the log.do page,why? I am puzzled with it! Anybody can tell me how to > > redirect my page with Javascript under Struts? > > > > Thanks > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >