Results 1 to 3 of 3
- 06-09-2010, 05:31 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 1
- Rep Power
- 0
- 06-10-2010, 02:48 AM #2
in this case, i assume that this is on a different page than the getpass.jsp and we want to on click make it go to to this getpass.jsp.
for an onClick() event handler, this is entirely a client-side javascript operation here. that is to say, this is not JSP specific.
perhaps you could use a HTML <form> with a hidden field(s) that you would stuff full of the parameters you would want to send to the second page. And then, have the onClick() post this form, instead of adjusting the location.href.
For example.
You could also have the option of making this be a POST or GET style request.Java Code:<form name="submitToGetPassForm" action="getpass.jsp"> <input type="hidden" name="param1" value="someValue"/> <input type="hidden" name="param2" value=""/> </form> <script type="text/javascript"> function doGetpass() { var form = document.forms['submitToGetPassForm']; // stuff some value into the form field form.elements['param2'].value='myothervalue'; form.submit(); } </script> <span onClick="doGetpass();">Bla bla bla</span>
Note its been a while since i've had to do JavaScript, so this is probably terrible coding:).
- 06-10-2010, 02:04 PM #3
This is how I do my passing,
var Customer Number = 273;
the param CN for Customer Number
onclick="location.href='http://localhost:8080/sampleajax/getpass.jsp?CN=273";
or put it in a variable
onclick="location.href='http://localhost:8080/sampleajax/getpass.jsp?CN="+CustomerNumber+""
than it will get carried to the next page where you will put this function at the top of your page,
thanJava Code:function gup( name ){ name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( window.location.href ); if( results == null ) return ""; else return results[1];};
var newpageCustomerNumber = gup ( 'CN' );
to get the variable:rolleyes: ~ Sno ~ :rolleyes:
'-~ B.S. Computer Science ~-'
Similar Threads
-
Pass parameter from one applet to another applet in different webpages...
By anubhavranjan in forum Java AppletsReplies: 2Last Post: 09-29-2009, 03:33 PM -
I can't seem to pass a file through a parameter
By daletron3030 in forum New To JavaReplies: 5Last Post: 01-15-2009, 06:07 AM -
Can a method take itself as parameter?
By bukake in forum New To JavaReplies: 10Last Post: 09-06-2008, 09:26 PM -
How to pass mysql string through a url parameter to a detail page query
By kwesiaryee in forum New To JavaReplies: 1Last Post: 08-22-2008, 06:28 PM -
How to pass two parameter in struts-config using dynaActionForm
By 82rathi.angara in forum Web FrameworksReplies: 2Last Post: 06-10-2008, 02:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks