• Post Reply Bookmark Topic Watch Topic
  • New Topic

Passign variable from javascript form to JSP

 
Kaiser M......
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone!
I am trying to pass a value from teh javascript form to the jsp processecs.. AND EVERY TIEM IT FAILS. I am converting this from php to JSP..
coudl anyone please help me..
thank you..
here it the problem
---form.html---
<HTML>
<HEAD><TITLE>WorldCom</TITLE>
<script language="JavaScript" type="text/javascript">
<!--
function getsupport ( selectedtype )
{
document.supportform.supporttype.value = selectedtype ;
document.supportform.submit() ;
}
-->
</script>
</HEAD>
<body>
<FORM name=supportform method=post action="form.jsp">
<A class=nav3 href=\"javascript:getsupport('Parts')\">Parts</A>
</form>
</html</body>

<--- start of jsp --- >
//form.jsp
<%

String supporttype =request.getParameter("supporttype");

out.print(" HELLO " );
out.print(" supporttype " + supporttype );

%>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firstly, welcome to the Ranch.
Secondly, please be more careful when typing in your posts. Your text and code example are so full of typos, it's hard to tell what could be the source of your problem. Also using the UBB CODE tags around your code makes it easier to read.
Lastly, where is the input element that corresponds to the 'supporttype' keyword? There doesn't appear to be any in your form.
hth,
bear
 
Kaiser M......
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
What I am trying to do here is, when the user clicks on the Parts link.. I am trying to capture which links the user clicked and display on the form.jsp... that the user had clicked e.g "Parts".
It works fine with php.. but i am having problems with the JSP thingy..
thanks
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I understand that. The point I was making is that in your JavaScript, you have:

but supportform has no 'supporttype' element.
I suspect that the addition of

to your form could be your fix.
hth,
bear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!