JavaScript - How To Check Check If Facebook Like Button Liked On My Webpage
On this webpage
http://www.corkdiscos.com/testimonials.html i have a like button. when a user clicks like a comment box appears. when i unlike the button the comment box disappears this is ok but when a user has already liked the facebook page and comes to my webpage the comment box does not show. so im looking for a piece of javascript to check if a user has like the button on my page and if so to show the comment box. please check my source code of the website http://www.corkdiscos.com/testimonials.html to see what i have so far. any help would be greatly appreciated Similar TutorialsHey, everyone! I was wondering if there was anyway to make a spell check button with JavaScript? I had an idea to disable spell check and then add a button so the user could click it to use spell check...or at least reveal the misspelled words. I'm sure that it's possible. In fact, I have a general idea of how it might be accomplished, but I'm not a JS coder so I don't know exactly how to make it work. Could anyone help, please? - Lono Hi all, This code works to place a mark in a radio button (check one) in a "restored" form: Code: for (var q=0;q<document.Simple.Colors.length;q++) { if (document.Simple.Colors[q].value == document.Restored.Colors.value) { document.Simple.Colors[q].checked = true ; break; } I'm curious why it won't work for a check box (check more than one): I figured it would be the same... no? Thanks, ~Wayne I currently have this script, I need it to check when I click the checkall button. Hm... now for some reason the select all button isnt working... Current code: Javascript: Code: <script type="text/javascript"> function checkall(chek) { for (i = 0; i < chek.length; i++) chek[i].checked = true; } </script> <script type="text/javascript"> function uncheckall(chek) { for (i = 0; i < chek.length; i++) chek[i].checked = false; } </script> PHP: PHP Code: <?php error_reporting(E_ALL); require("inc/config.php"); if (isset($_POST['del'])) { for ($count = 0;$count<count($_POST[delchk]);$count++) { $delete = $_POST[delchk][$count]; $query = "DELETE FROM persons WHERE id = '$delete'"; $result = mysql_query($query); if (!$result) { die("Error deleting persons! Query: $query<br />Error: ".mysql_error()); } } } $result = mysql_query("SELECT * FROM persons"); // Check how many rows it found if(mysql_num_rows($result) > 0){ echo "<table id=\"mytable\"> <thead> <tr> <th align=\"center\" scope=\"col\">Delete</th> <th align=\"center\" scope=\"col\">First Name</th> <th align=\"center\" scope=\"col\">Last Name</th> <th align=\"center\" scope=\"col\">High Scores</th> <th align=\"center\" scope=\"col\">Date of Entry</th> <th align=\"center\" scope=\"col\">IP Address</th> </tr> </thead> <tbody>"; echo "<form name = 'myform' action='' method='post'>"; while($row = mysql_fetch_array($result)) { echo "<tr align=\"center\">"; echo '<td><input type="checkbox" id="delchk" name="delchk[]" value="'.$row['id'].'" /></td>'; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "<td><a target=frame2 href='" ."profile.php?user1=". $row['FirstName'] ."'>Check HighScores</a></td>"; echo "<td>" . $row['AddedDate'] . "</td>"; echo "<td>" . $row['Ip'] . "</td>"; echo "</tr>"; } echo "</tbody>"; echo "</table>"; echo "<hr>"; echo "<input type='submit' name = 'del' value='Delete Selected'></form>"; echo "<input type='button' onclick='checkall(document.myform.delchk);' value='Select All'>"; echo "<input type='button' onclick='uncheckall(document.myform.delchk);' value='UnSelect All'>"; } else{ // No rows were found ... echo "No Registered Members"; echo "</tbody>"; echo "</table>"; } mysql_close($con); ?> iframe Info: id="AssessmentsIFrame" button Info: id="wpv_1266351" I have 3 check boxes and one submit button when the submit button is hit I need it to direct to one of 3 pages depending on which check box is checked. can anyone help with this Thanks! Hey All! I've been having problems trying to figure this out and my nooby skills can only go so far... Basically I have a page that allows a user to select a specific category which links them to another page that has a series of radio buttons. By default I want to have that category checked according to what they selected. I've been able to pass the category variable with no problem but can't get it to default check... So far my Javascript looks like this: Code: <script type="text/javascript"> var category = category3 function autoForm(){ var searchForm = document.getElementById('myform'); var searchInput = searchForm.getElementsByTagName('input'); if(searchInput.value == category){ searchInput["group"].checked = true; } else { searchInput["group"].checked = false; } } <script> And so I'm trying to search with that function the value rather than the name. Here is my HTML: Code: <body onload="autoForm();"> <form id="myform" name="myform" action="#" method="POST"> <div align="center"><br> <input type="radio" name="group" value="category1"> Milk<br> <input type="radio" name="group" value="category2"> Butter<br> <input type="radio" name="group" value="category3"> Cheese<br> <input type="radio" name="group" value="category4"> Bread<br> </div> </form> </body> </html> I'm not getting any javascript errors, but nothing is really happening. So ultimately I want it to default select whatever the category variable (in this case "category3") when the user opens up the page. I'm trying to learn javascript right now so I'd love to hear how this is failing and how to do it right. I spent soooo long trying to figure this out. [woot! first post] Hi guys. I'm working a bunch of pre existing code on a CMS. Just after a quick fix. Doing a show/hide thing on a particular div somewhere on the page depending if a checkbox is ticked or not. Currently there is 3 checkboxes that are dynamically added through the CMS. Here's simplified version of the form: Code: <form id="simplesearch" name="simplesearch"> <input type="checkbox" onclick='showhidefield(this.value)' name="meta_data_array_search_criteria[custom_profile_type][]" value="5" class="input-checkboxes" /> <input type="checkbox" onclick='showhidefield(this.value)' name="meta_data_array_search_criteria[custom_profile_type][]" value="4" class="input-checkboxes" /> </form> And here's the javascript I was playing with. Code: function showhidefield(id) { if(document.simplesearch.meta_data_array_search_criteria[custom_profile_type][''].checked) { document.getElementById("profile_fields_wrapper_" + id).style.visibility = "visible"; } else { document.getElementById("profile_fields_wrapper_" + id).style.visibility = "hidden"; } } Problem I'm having is how do i do a check to see if those checkboxes are checked in the javascript with those name arrays? How do i separate them? 'm guessing I have to loop through them or something?Hopefully that make senses - it's late here and I'm losing the plot Any pointers would be gratefully welcomed Hey I'm looking to create a button like Facebook has that just says Like. Since I have little JavaScript experience I was wondering if anyone could point me towards a tutorial or code me one. I could do it with just a link and PHP but I want to use Ajax. http://venturebeat.com/wp-content/up...ike1020909.png I have three divs, Step 1, Step 2, Step 3. I'm trying to get it so when a person clicks the Facebook Like, the style changes to none and Step 2 is revealed and when the Facebook Share is clicked, the Step 3 is revealed. But when I like the first thing, it doesn't change to Step 2. Any thoughts? Code: <div id="Step1"><table border="0" width="630" height="174" background="images/step1-2.jpg"><tr><td valign="top" align="left" style="padding-left: 215px; padding-top: 80px"><br /> <iframe src="http://www.facebook.com/plugins/like.php?href=LINKHERE&layout=standard&show_faces=false&width=450&action=like&font=arial&colorscheme=light&height=35" scrolling="no" action="like" frameborder="0" style="border:none; overflow:hidden; width:450px; height:35px;" allowTransparency="true"></iframe> <br /> </tr></td></table></div><div id="Step2" ><table border="0" style="display: none" width="630" height="174" background="images/step2-2.jpg"><tr><td valign="top" align="left" style="padding-left: 210px; padding-top: 82px"><br /> <a name="fb_share" type="button" share_url="LINKHERE"></a> <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"> </script> <br /> </tr></td></table></div><div id="Step3" style="display: none"><table border="0" width="630" height="174" background="images/step3-2.jpg"><tr><td valign="top" align="left" style="padding-left: 210px; padding-top: 72px"><br /> <center><a href="LINKHERE">Download Here</a> </center></tr></td></table></div><br /> <script type="text/javascript"> window.fbAsyncInit = function() { FB.init({appId: 'ID HERE', status: true, cookie: true, xfbml: true}); FB.Event.subscribe('edge.create', function() { document.getElementById('Step1').style.display = 'none'; document.getElementById('Step2').style.display = 'block'; document.getElementById('Step3').style.display = 'none'; setTimeout('document.getElementById(\'Step1\').style.display = \'none\';document.getElementById(\'Step2\').style.display = \'none\';document.getElementById(\'Step3\').style.display = \'block\';', 7000); }); }; (function() { var e = document.createElement("script"); e.type = 'text/javascript'; e.src = document.location.protocol + "//connect.facebook.net/en_US/all.js"; e.async = true; document.getElementById("fb-root").appendChild(e); }()); </script> I've been told by many reliable sources that getting people to 'like' your site on Facebook is a great way of increasing your site traffic and getting a site ranked higher on Google and other search engines. However, it is hard work to get it implemented correctly. What you want is to have each page individually 'liked' rather than the site as a whole. To do that can take a lot of time-consuming fiddling around. We've created a simple piece of Javascript that allows you to create a custom 'like' button on each page of your site. Because we've had some help from other members with some bits and pieces of Javascript coding, it only seems fair to share something in return. Prerequisites You will need to get a Facebook Application ID from Facebook themselves. This is a unique Application ID for your domain. The easiest way to get one of these is to go to http://developers.facebook.com/docs/.../plugins/like/ and enter the details for your domain. Then click on 'GET CODE' and copy the 15 digit number from #appId. You then paste this into the Javascript as shown below. Adding the Facebook 'like' button to each page - changes to HTML In the <head> section of your HTML, add the following piece of code: Code: <script type="text/javascript" src="SocialMedia.js"></script> <script type="text/javascript"> FacebookSetup('Your page title goes here', 'image-to-show-on-Facebook.jpg'); </script> At the point on the page where you actually want the 'Like' button to appear, you then add the following piece of code: Code: <script type="text/javascript"> FacebookLike(); </script> The JavaScript Now create a JavaScript file called SocialMedia.js: Code: var facebookAppID = "xxxxxxxxxx" function FacebookSetup(title, image) { var url=window.location.host + window.location.pathname; document.write("<meta property='og:title' content='" + title + "' />"); document.write("<meta property='og:type' content='article' />"); document.write("<meta property='og:url' content='" + url + "' />"); document.write("<meta property='og:image' content='" + hostname + "/images/" + image + "' />"); document.write("<meta property='og:site_name' content='" + sitename + "' />"); document.write("<meta property='fb:admins' content='" + facebookAppID + "' />"); } function FacebookLike() { var facebook="http://www.facebook.com/plugins/like.php?href=" + url + "&layout=standard&show_faces=false&width=250&action=like&font&colorscheme=light&height=35"; document.write("<iframe src=" + facebook + " scrolling=no height=35 frameborder=0 style=border:none; overflow:hidden; width:250px; height:35px; allowTransparency=true></iframe>"); } Change the value in the variable facebookAppId on line one to your Application ID (as explained in the prerequisites section above). What happens once you've implemented this? Once you've implemented this, you should see a LIKE button on your page. If you are a Facebook user and have cookies set to always log you in, you'll find that when you click on this LIKE button, a link to your page will appear on your Facebook page, along with a thumbnail photograph as specified by you when you called FacebookSetup in your HTML code. Other people who follow you on Facebook will then also have the link to your site appearing on their News Feed. If you are not logged in when you click on the LIKE button, you will be prompted to log on to Facebook before the information appears on your News Feed. What are the benefits of using JavaScript to do this, rather than writing the HTML code for each page? Many sites have created a blanket site-wide 'LIKE' button and embedded it into their HTML. Whilst this is easy, it is limiting - the LIKE button always has the same title, the same picture and sends you to the same page on your website. Of course, it is possible to write custom HTML for each page, but this can soon get messy and then becomes more difficult to maintain. As an alternative, this JavaScript is simple and tidy. The code makes it simple to create unique Facebook 'likes' for each page, with custom text and custom images. It also keeps your HTML tidy, thereby making it easy to maintain in the future. Hope this helps, folks. I have a text input box that resets to blank when the user enters an alpha character, it also checks for the number 0 as it has to be greater than 0 too... when I submit the form it is blank the variable changes to blank (as I use parseInt to convert it to an integer at a later stage) What can I do to check and see if it is NaN value? (I've tried isNaN() and it did not do what I wanted it to) this code is supposed to ask the users name and say how many letters in it get 2 random numbers ask user to add them if right say Well Done! if wrong say Sorry, you are wrong. when i run this nothing comes up whats wrong? thanx Code: <script> var firstName = ""; var numLetters = 0; firstName = prompt("Hi, what's your first name?", ""); numLetters = firstName.length; alert ("Did you know there are " + numLetters + " letters in your name?"); var num1 = Math.floor(Math.random()*9) + 1; var num2 = Math.floor(Math.random()*9) + 1; var answer; var useranswer; answer = num1+num2; useranswer = promt("What is" + num1 + "+" + num2 + "?"); If (answer = useranswer) { alert("Well done!"); } else { alert("Sorry, you are wrong."); } </script> I need to create some javascript code that asks a user a series of yes/no questions. Depending on how the user answers it will direct them to additional yes/no questions or simply stop with a message that they are not eligible. I need something similar to this site: http://www.kingfoundation.com/Grants...lity-Quiz.aspx Any help to develop this code would be much appreciated as I am a fairly inexperienced developer. I have been banging my head on the wall with this one for a few hours. I mostly only program bash so this is a new world for me. I am trying to have a script check a list of zip codes(preferably from a file) and if it is there it passes it to an order page and if not it goes to another URL. The basic idea is to check if you are within a service area before you can purchase a product. I have gotten nowhere fast with this so any help you can offer would be appreciated. I have NO knowledge of Javascript at all but borrowed and attempted to adapt one I found. It is a Firefox bookmarklet designed to highlight in different colours both certain words or the ending "ing" on a word in a text document that has been saved as html. Basically it is a device for helping novel writers rid their manuscripts of redundant words and overuse of the 'ing" words. In works in part but doesn't pick up all "ing" endings. For someone who know what their doing I imagine it would take more than a few minutes to read and correct. Many thanks to anyone who can help. Here is the Javscript: javascript:var%20verbsRE=/(\b)(about|actually|almost|already|appear|approximately|basically|close to|even|eventually|exactly|finally|here|just|kind of|nearly|now|practically|really|seem|simply|somehow|somewhat|sort of|suddenly|then|there|truly|utterly|while|as|appear|felt|gaped|gawked|gazed|glanced|hear|heard|knew |looked|noticed|observed|peered|peeped|regarded|saw|scanned|see|seeing|seemed|smelled|stared|studied |surveyed|tasted|viewed|watched)(\b)/gi;var%20ingRE=/(\w)(ing)(\b)/gim;function%20HL(node){if(node.hasChildNodes){var%20hi_cn;for(hi_cn=0;hi_cn<node.childNodes.length; hi_cn++){HL(node.childNodes[hi_cn]);}}if(node.nodeType==3){var%20tempNodeVal=node.nodeValue;if(verbsRE.test(tempNodeVal)){tempNodeVal= tempNodeVal.replace(verbsRE,"$1<span%20style='background-color:yellow;color:black;border:1px%20solid%20black;'>$2</span>$3");tempNodeVal=tempNodeVal.replace(ingRE,"$1<span%20style='background-color:#0ff;color:black;border:1px%20solid%20black;'>$2</span>$3");newNode=document.createElement('span');newNode.innerHTML=tempNodeVal;pn=node.parentNode;pn .replaceChild(newNode,node);}}}HL(window.document.getElementsByTagName('body')[0]); Hello, I have never used javascript before, so this might be a very basic question. I have a script on my blog which places a stumbleupon button on the page. This is the code that calls the script: Code: <script src="http://www.stumbleupon.com/hostedbadge.php?s=5"></script> Today I went to my blog and it was taking a long time to load, it turns out because stumbleupons site is down so the script can't be accessed. A whole lot of other stuff on the page just doesn't load until it times out though, so it takes like 3 minutes for the page to load. What I want to know is can I test if the script is reachable and only call it if it is, so that if there is a 403 or 404 error it just won't even try to load it and continue loading the rest of the page?? Any help is greatly apprectiated! Thanks. I am trying to add values from 6 text boxes and display its sum automatically in 7th text box. This is not working. Please help. function calculate_a() { var a = document.getElementById('Para_A_A1_score').value ; var b = document.getElementById('Para_A_A2_score').value ; var c = document.getElementById('Para_A_A3_score').value ; var d = document.getElementById('Para_A_A4_score').value ; var e = document.getElementById('Para_A_A5_score').value ; var f = document.getElementById('Para_A_A6_score').value ; var g = (a+b+c+d+e+f) ; document.audit_billing_IE.product_name4.value = g ; } Quote: Below is the html form code that should automatically display the total value without clicking on any submit or send button <tr> <td> Parameter A </td> <td colspan='3'> <input type="text" name="product_name4" id="product_name4" onchange="calculate_a(this);" /> </td> </tr> This is the code part that fails it's if check. Code: while (n<=30) { var slot='#slot'+n; $( slot ).data({no: n, id: itemId[i], name: itemName[i], equip: itemEquip[i], lvl: itemLvl[i], bonus: itemBonus[i], rstr: itemRStr[i], rdef: itemRDef[i]}); $( slot ).draggable({ handle: slot, stack: slot, revert: "invalid", snap: "div#"+itemEquip[i], snapMode: 'inner', start: function(event, ui) { $('div#'+$(this).data('equip')).css({'border': '2px dashed #0066CC', 'background': 'rgba(255,255,255,0.2)'}) .droppable ({ drop: function(event, ui) { if (pLvl>=$('.ui-draggable-dragging').data('lvl') && pStr>=$('.ui-draggable-dragging').data('rstr')) { alert(pLvl+", "+$('.ui-draggable-dragging').data('lvl')); $('.ui-draggable-dragging').css({'display':'none'}); $('div#'+$('.ui-draggable-dragging').data('equip')).html ( "<img src='items/equipped/"+$('.ui-draggable-dragging').data('name')+$('.ui-draggable-dragging').data('id')+".png' />" ) $.ajax({type:"GET", url:"items/change.php", data:"id="+$('.ui-draggable-dragging').data('id')+"&no="+$('.ui-draggable-dragging').data('no'), cache:false, timeout:5000, error: function() { $('div.nogood').html ( "There was an error. Please inform us about it in the forum." ).css({'width':'400px','margin-left':'-200px'}); $( 'div.nogood' ).fadeIn(500, away); function away() { $( 'div.nogood' ).delay(2000).fadeOut(500); }; } }); } else { alert("HUh"); $( 'div.nogood' ).fadeIn(500, away).css({'width':'400px','margin-left':'-200px'});; $('.ui-draggable-dragging').draggable({revert: true}); if (pLvl<$('.ui-draggable-dragging').data('lvl')) { alert("Good"); } else if (pStr<$('.ui-draggable-dragging').data('rstr')) { $('div.nogood').html("Not enough strength.") } function away() { $( 'div.nogood' ).delay(1400).fadeOut(500); }; } } }); }, stop: function(event, ui) { $('div#'+$(this).data('equip')).css({'border':'none', 'background':'transparent'}).droppable("destroy"); } }); n++; i++; } This if comparison if (pLvl>=$('.ui-draggable-dragging').data('lvl') && pStr>=$('.ui-draggable-dragging').data('rstr')) somehow goes through. After the if statement I check the values with the alert but it displays 5 for pLvl and 10 for the draggables data (which are the correct numbers) so can anyone tell me why does this if statement still go through when pLvl is lower? I was wondering if there was a simple way of notifying a user who has entered an incorrect postcode? I have found numerous answers to this problem but i am sure there is a simpler way to do it as ones i have found have rows and rows of code. Help is much appreciated |