Click here to Skip to main content
15,885,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

i am using the radiobutton but it not working in the blur....

HTML
 <div id="sports" class="weather col-lg-12 col-md-12 col-sm-12 col-xs-12" style="width:100%;">
                                    <form method="post" action="/SportsDept/Create"  name="second" id="second">
<span class="status"></span>
@foreach (var t in sptname)
    {
     <br />
     <span class="status" ></span>
     <input name="Players[0].Level" id="Players_0__Level" type="radio" checked="checked" value="BEG"><label for="Players_0__Level">@t</label>
    }
      </div>

HTML
<script>
    $("#Players_0__Level").on("click", function () {
        location.href = '/SportsDept/Create/' + $(this).find('Players[0].Level').text();
    });
</script>


some time the foreach sptname name have more than two values...

i want to redirect the page on clicking the radiobutton...

here works only the first radiobutton second and third are not working..

and i want to pass the radiobutton name to the nextpage..

in mvc5..

i don't know this details enough for give a correct solution !!!


Regards
AR
Posted
Updated 12-Mar-14 3:23am
v2

1 solution

Try:

JavaScript
<script>
    $("#Players_0__Level").each(function(){ $(this).on("click", function () {
        location.href = '/SportsDept/Create/' + $(this).find('Players[0].Level').text();
    })});
</script>
 
Share this answer
 
Comments
An@nd Rajan10 13-Mar-14 1:43am    
this is not working..
Shelby Robertson 13-Mar-14 9:54am    
your problem is that the id for multiple elements are same. That isn't valid. You need to change your for loop to give each input and label a unique ID. Do you need me to write out an example?
Shelby Robertson 13-Mar-14 10:00am    
http://jsfiddle.net/7fRB6/1/

Here is a jsFiddle with an example of it working

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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