I have an aspx page with this carousel of images that are buttons at the same time:
<div id="carousel">
<figure><asp:ImageButton id="puzzle1" ImageUrl="~/images/puzzle1.jpg" class="img-rounded img-responsive image" runat="server" OnClientClick="showModel('uno'); return false"/></figure>
<figure><asp:ImageButton id="puzzle2" ImageUrl="~/images/puzzle2.jpg" class="img-rounded img-responsive image" runat="server" OnClientClick="showModel('dos'); return false"/></figure>
<figure><asp:ImageButton id="puzzle3" ImageUrl="~/images/puzzle3.jpg" class="img-rounded img-responsive image" runat="server" OnClientClick="showModel('tres'); return false"/></figure>
<figure><asp:ImageButton id="puzzle4" ImageUrl="~/images/puzzle4.jpg" class="img-rounded img-responsive image" runat="server" OnClientClick="showModel('cuatro'); return false"/></figure>
<figure><asp:ImageButton id="puzzle5" ImageUrl="~/images/puzzle5.jpg" class="img-rounded img-responsive image" runat="server" OnClientClick="showModel('cinco'); return false"/></figure>
<figure><asp:ImageButton id="puzzle6" ImageUrl="~/images/puzzle6.jpg" class="img-rounded img-responsive image" OnClick="linkButton6_Click" runat="server"/></figure>
</div>
Each of these buttons has a function OnClientClick="showModel(PARAMETRO);
Below, behind the body HTML
I have that same function declared in the following form:
<script>
function showModel(variable) {
if (variable == "uno") {
'<%Session["tipoPuzzle"] = "uno"; %>';
}
if (variable == "dos") {
'<%Session["tipoPuzzle"] = "dos"; %>';
}
if (variable == "tres") {
'<%Session["tipoPuzzle"] = "tres"; %>';
}
if (variable == "cuatro") {
'<%Session["tipoPuzzle"] = "cuatro"; %>';
}
if (variable == "cinco") {
'<%Session["tipoPuzzle"] = "cinco"; %>';
}
$('.modal').modal();
}
</script>
The main job of this function is:
Based on the user's click, fill in a session variable and open another page (dynamic) which is built based on that session variable.
The problem is that I always touch the 'five' parameter and nothing else. Click where you do, only the 'five' parameter travels.
I want to ask you for help with that problem and if you see any way to optimize the function, your advice is welcome.