DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   Passing paramter from javascript to jsp (http://www.daniweb.com/forums/thread27681.html)

Soni_7 Jul 8th, 2005 3:30 am
Passing paramter from javascript to jsp
 
Hi ,

I have a function as :
function doCheck(str1,str2)
{
top.LocalCacheLoadStatus = false;
parent.SearchFrame.location.href=str1;
g_str_Mode = str2;
alert (g_str_Mode);
}

This has str1 as the name of the jsp file and str2 is the value which i have to pass to the jsp file given in str1.How do i do that ?

Thanks & Regards
Soni

Troy Jul 8th, 2005 6:36 pm
Re: Passing paramter from javascript to jsp
 
Try this:
function doCheck(str1,str2) { 
  top.LocalCacheLoadStatus = false;
  parent.SearchFrame.location.href=str1;
  g_str_Mode = str2;
  alert (g_str_Mode);
  var url = str1+".jsp?str2="+str2;
  alert(url);
  document.location = url;
 }

If you need to pass the variable to the jsp page, and you don't need your user to ever see the output from that jsp page--that is, you want the user to stay on the current page without noticing the value was submitted, you can use a hidden iframe--and navigate it instead of your main page. You can also use an AJAX solution, but an iframe does just fine and is easier to make compatible across browsers.

Soni_7 Jul 11th, 2005 3:29 am
Re: Passing paramter from javascript to jsp
 
Hi,
Thanks a lot. I hope it works.Let me try.

Regards,
Soni


All times are GMT -4. The time now is 3:42 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC