mvkraju
asked on
how to pass query string when user click on hyperlink text
Hi,
In my JSP page i have hyper text link. Below that link i will have 3 radio buttons. When user click on the hyper link i want pass the value of selected radio button as a query sting with the URL i mention at <a href="url"> tag.
Here is my code but it's not working, i am getting envType value as null
<BODY>
<%
String envtype = request.getParameter("envT ype");
%>
<TABLE width=600 BORDER=0>
<TR>
<TD><a href="/iaInformation/index .do?envTyp e=<%=envty pe%>" ><bean:message key="mwr.link.msg.whows.rp t" /></a></TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="T" checked>Test Environment (T01, T02, T03, T04)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="Q" >QA Environment (Q01)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="P" >Production Environment (P01)</TD>
</TR>
</TABLE>
</BODY>
Please correct me if i am doing wrong.
I appreciate ur help!
Thanks
In my JSP page i have hyper text link. Below that link i will have 3 radio buttons. When user click on the hyper link i want pass the value of selected radio button as a query sting with the URL i mention at <a href="url"> tag.
Here is my code but it's not working, i am getting envType value as null
<BODY>
<%
String envtype = request.getParameter("envT
%>
<TABLE width=600 BORDER=0>
<TR>
<TD><a href="/iaInformation/index
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="T" checked>Test Environment (T01, T02, T03, T04)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="Q" >QA Environment (Q01)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="P" >Production Environment (P01)</TD>
</TR>
</TABLE>
</BODY>
Please correct me if i am doing wrong.
I appreciate ur help!
Thanks
For this to work, you need to have /iaInformation/index.do defined in your struts config and working.
<BODY>
<%
String envtype = request.getParameter("envT ype");
%>
<TABLE width=600 BORDER=0>
<html:form action="/iaInformation/ind ex.do" method="GET" >
<TR>
<TD>
<bean:message key="mwr.link.msg.whows.rp t" /></a></TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="T" checked>Test Environment (T01, T02, T03, T04)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="Q" >QA Environment (Q01)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="P" >Production Environment (P01)</TD>
</TR>
</TABLE>
</html:form>
</BODY
<BODY>
<%
String envtype = request.getParameter("envT
%>
<TABLE width=600 BORDER=0>
<html:form action="/iaInformation/ind
<TR>
<TD>
<bean:message key="mwr.link.msg.whows.rp
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="T" checked>Test Environment (T01, T02, T03, T04)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="Q" >QA Environment (Q01)</TD>
</TR>
<TR>
<TD class='normal'><input TYPE="radio" NAME="envType" VALUE="P" >Production Environment (P01)</TD>
</TR>
</TABLE>
</html:form>
</BODY
ASKER
In my example i mentioned only one hyperlink. But actually i have 2 hyperlinks, for the 2 URLs i want to pass this query string.
princeamin, in that case how does it work?
princeamin, in that case how does it work?
ASKER
If it is not possible this way.
Can i do it using javascript?
but i have no idea how to assign a value which i get it from JS?
Please give me some suggestions!!!
Thanks
Can i do it using javascript?
but i have no idea how to assign a value which i get it from JS?
Please give me some suggestions!!!
Thanks
ASKER
I am increasing points, if it is difficult.
instead of
><a href="/iaInformation/index .do?envTyp e=<%=envty pe%>" ><bean:message key="mwr.link.msg.whows.rp t" /></a>
you could use something like
><a href="#" onclick="this.href = '/iaInformation/index.do?e nvType=' + document.formname.envType. value;"><b ean:messag e key="mwr.link.msg.whows.rp t" /></a>
I did not check my javascript code. You might have change the way I access envType's value. rrz
><a href="/iaInformation/index
you could use something like
><a href="#" onclick="this.href = '/iaInformation/index.do?e
I did not check my javascript code. You might have change the way I access envType's value. rrz
ASKER
rrz
when i print the envType value in the servlet.
it prints envType value as 'undefined'.
am i mising anything else?
i did exactly as you said.
when i print the envType value in the servlet.
it prints envType value as 'undefined'.
am i mising anything else?
i did exactly as you said.
ASKER
rrz... i could see the follwong URL in my browser
http://localhost:9080/iaInformation/index.do?envType=undefined
Thanks
http://localhost:9080/iaInformation/index.do?envType=undefined
Thanks
ASKER
here is my code
<a href="#" onclick="this.href='/iaInf ormation/i ndex.do?en vType='+do cument.ind ex.envType .value;" ><bean:message key="mwr.link.msg.whows.rp t" /></a>
am i doing anything wrong.
my form name is index
<a href="#" onclick="this.href='/iaInf
am i doing anything wrong.
my form name is index
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>var envType = "T";
maybe I should have used
var envType = document.index.envType[0]. value;
maybe I should have used
var envType = document.index.envType[0].
ASKER
rrz.. it seams javascript is working fine. It's picking up right envType value.
But some how when i click on the link, it's not calling /iaInformation/index.do link.
I guess there is some thing wrong in the following statement
document.links[0].href
But some how when i click on the link, it's not calling /iaInformation/index.do link.
I guess there is some thing wrong in the following statement
document.links[0].href
ASKER
sorry rrz...
It's working fine. Actually i have links in my page, so when i changed
document.links[0].href to document.links[1].href
it's working fine.
Thanks
It's working fine. Actually i have links in my page, so when i changed
document.links[0].href to document.links[1].href
it's working fine.
Thanks
>Please correct me if i am doing wrong.
You are trying to use JSP on the client side. JSP is at the server and JavaScript is in the browser.
rrz