0

Im new to javascript and jquery. my website has jquery running.

It want to change css-link using radio-buttons

It has the following radio buttons:

<input type="radio" name="css" value="basic" checked>basic
<input type="radio" name="css" value="round" >round
<input type="radio" name="css" value="zoom" >zoom

What i need is, when user change radio button, the script should get the current url (eg. http://mysite.com/about.php) and add the selected button value as a query string (eg. http://mysite.com/about.php?css=round) and redirect to that link with query-string. (if current link has ?css=basic it should change it to ?css=round...)

thanks

user2444417
  • 45
  • 1
  • 8

2 Answers2

0
 $("input:radio").each(function(){
        $(this).click(function(){
            window.location.href = "http://mysite.com/about.php" + "?css=" + $(this).val();
        });
    });
Manish Parmar
  • 859
  • 1
  • 11
  • 19
0

a quick google search gets you the answers!

this is for binding your function to an event

this is for the redirect

this is to get the current url

this is for getting the url without the query string

and this helps for figuring out how to use the reg exp

Community
  • 1
  • 1
yardarrat
  • 280
  • 3
  • 14