I have this piece of code,
<a href="#" id="addtoteam">
Add to Team
</a>
, and if I click this link, a modal dialog will appear,
$('#addtoteam').click(function(){
var url = '<?php echo BASEURL;?>';
$( "#dialogbox" ).dialog({
autoOpen: true,
buttons: {
"Use Registration Credits": function(){
// execute something here before redirecting it to another page, perhaps perform the updating of the registration_credits of each team here
window.location = url + '/administration/add_to_team/' + teamID +'/'+ playerID +'/?credit=1';
},
"Pay Extra Charge": function() { $(this).dialog("close"); },
"Cancel": function() { $(this).dialog("close"); }
},
width: 800
});
});
As you can see I have three buttons, take a look at the “Use Registration Credits” button, if it is chosen, it will redirect to another page, but what I want is if it redirects to other page, I want to have the url looking like this,
sample.com/administration/add_to_team/team_id/player_id?credit=1
Now my question is, is it possible to pass any value that can be assigned to a variable inside my click() function such that this value can be my team_id or player id? I hope I explained clearly. Thanks.
you can store parameters like team_id or player id in your element as attributes:
then you get these with:
Hope It can help you