Subscribe
-
-
Recent Posts
Recent Comments
- Michael on Voting System Youtube Style With jQuery & PHP
- programmer on Post Picture to Facebook User Wall with PHP
- Babak on Login with Google using PHP API library
- DjLexsas on Simple Ajax Pagination with jQuery & PHP
- thusitha on Voting System Youtube Style With jQuery & PHP
Popular Posts
- Ajax Image Upload with Progressbar with jQuery and PHP
- Post to Facebook Page Wall Using PHP + Graph
- 40+ CSS Buttons from codepen
- Ajax Add & Delete MySQL records using jQuery & PHP
- Ajax Image Upload and Resize with jQuery and PHP
- Simple Ajax Pagination with jQuery & PHP
- PayPal Express Checkout with PHP
- 30 Pure CSS3 Tutorials & Examples
- Post on Facebook wall using PHP
- Loading More Results From Database Using jQuery Ajax
- Login with Google using PHP API library
- Ajax Facebook Connect with jQuery & PHP
-
Best 10 WordPress Plugins for all Bloggers
WordPress itself is a lethal weapon, without any plugins installed. In-fact you don’t need anything at all, it has everything you ever need. But with some fine quality plugin, your blog can do wonders and it starts to shine. But be careful with all the selection, useless & buggy plugins can turn your dreams into nightmare.
Get Selected Values From Radio Button using jQuery
Let’s say you have following radio options for the user, and you need to retrieve the value from selected radio button using jQuery.
1 2 3 4 5 | <div>Choose option:</div> <input type="radio" name="user_options" value="css" /> CSS <input type="radio" name="user_options" value="jquery" /> jQuery <input type="radio" name="user_options" value="html" /> HTML <input type="radio" name="user_options" value="xml" /> XML |
This jQuery line below retrieves the value of selected radio box.
1 | var checked_site_radio = $('input:radio[name=user_site]:checked').val(); |
But when radio isn’t checked, “undefined” error returns, to deal with undefined value do this :
1 2 3 4 5 | var checked_site_radio = $('input:radio[name=user_site]:checked').val(); if(checked_option_radio!=undefined) { //do stuff } |
The complete example :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <!DOCTYPE html> <html> <head> <title>Radio Button Selection</title> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#radio_submit").click(function (e) { var checked_option_radio = $('input:radio[name=user_options]:checked').val(); var checked_site_radio = $('input:radio[name=user_site]:checked').val(); if(checked_option_radio===undefined || checked_site_radio===undefined) { alert('Please select both options!'); }else{ alert('Your option - "' +checked_option_radio + '", and site - "'+ checked_site_radio +'"'); } }); }); </script> </head> <body> <form id="myform"> <div>Choose option:</div> <input type="radio" name="user_options" value="css" /> CSS <input type="radio" name="user_options" value="jquery" /> jQuery <input type="radio" name="user_options" value="html" /> HTML <input type="radio" name="user_options" value="xml" /> XML <div>Another option:</div> <input type="radio" name="user_site" value="Google" /> Google <input type="radio" name="user_site" value="Yahoo" /> Yahoo <input type="radio" name="user_site" value="Facebook" /> Facebook <input type="radio" name="user_site" value="Twitter" /> Twitter <div><button id="radio_submit" type="button">Show Selected Radio</button></div> </form> </body> </html> |
Demo
Joomla Module to Display Twitter Buttons
Joomal module will display twitter buttons in any Joomla template positions. Module can be configured to display any twitter button you want. There are four buttons: Follow on Twitter, Share on Twitter, Twitter Hashtag and Twitter Mention. Each button can be configured exactly like Twitter Button Generator, all you need to do is enter your twitter username and you are ready to go.
.htacess redirect from subdomain to full URL
Sometimes, Google or other search engines start to crawl your subdomains, indexing everything without your knowledge. And your search results start to appear something like this – http://subdomain.mainsite.com/page.html, instead of http://mainsite.com/page.html. All paths to pages are same except the subdomain added to the URL.
To redirect all your subdomains to main site URL, add following line in your .htaccess file.
1 2 3 | RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?[^.]+.mymainsitename.com.*$ RewriteRule (.*) http://mymainsitename.com/$1 [L] |

-

-

-

-

Saaraan On