I have the following code for my webpage. It's pure basic but it doesn't do what I want somehow.

What is should do is, it should change the action target depending on the radio button selection. It doesn't even run the function. Could you please guide me what I am doing wrong?


You may find the same code: http://pastebin.com/5jjGQQkA

form id="choose_dept" method="POST" action="http://mywebsite.com/">


  <script type="text/javascript">


  $("#choose_dept").attr('action', 'http://mywebsite.com/' + $('input[name=section]:checked').val() + '/' );

            <input id="section_1" type="radio" name="section" value="tr1">
            <input id="section_2" type="radio" name="section" value="tr2">
            <input id="section_3" type="radio" name="section" value="tr3">