Click here to Skip to main content
15,896,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
What i would like to do is to pass my js function's parameter to link when opening other jsp.

Here's the code:

JavaScript
function openDialog(myVariable){
$('div#dialogbox').dialog({
buttons:{
'OK': function(){
window.location.href="otherfile.jsp?id= '; //I want myVariable value after "id="
}}});
}
Posted

Change the code from

JavaScript
function openDialog(myVariable){
$('div#dialogbox').dialog({
buttons:{
'OK': function(){
window.location.href="otherfile.jsp?id= '; //I want myVariable value after "id="
}}});
}


To

JavaScript
function openDialog(myVariable){
$('div#dialogbox').dialog({
buttons:{
'OK': function(){
window.location.href="otherfile.jsp?id="+myVariable; 
}}});
}


Hope the above changes help.
 
Share this answer
 
There is no such thing as "passing a parameter to link". Javascript parameters have nothing to do with link parameters (you probably mean URL parameters). What you need are just pure simple string manipulations. For example, if the Javascript function parameter is a value for the parameter id (name everything in semantically sensible way! naming variable using the word "variable" is… will, non-informative), you could simple concatenate the string, something like "otherfile.jsp?id=" + myVariable.
—SA
 
Share this answer
 
fiddle to check the windiw.location.href[^]
I have created this fiddle, that would on click of the button show an alert and then in a div "My code project account would come for some seconds as the whole page is being rendered", I have passed the membership id as the parameter. Check that out. This would hopefully clear your query.
Thanks
Happy Coding :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900