Answered by:
Javascript Facebook Intergration

Question
-
User-308590806 posted
Hi guys
I am wondering how I can get a javascript questionare to contain a button that posts the result onto the current users facebook wall. here is a simple version of the code I am using .. any help would be greatly appreciated.
<html> <head> <title>Game suggestion application</title> <script type="text/javascript"> //This is our game list, which makes it easy to add new games var games = [ { name: 'Battlefield 3', type: 'fps', preference: 'tactical' }, { name: 'Call of Duty', type: 'fps', preference: 'tactical' }, { name: 'Starcraft', type: 'rts', preference: 'tactical' } ]; /// <summary> /// Returns an array of game suggestions based on on the supplied type and preference /// </summary> function getGameSuggestions(lookingForType, lookingForPreference){ var suggestedGames = []; //Loop through our game list and add each item which matches type and preference to our suggestion list. for(var i = 0; i < games.length; i++){ var currentGameToCheck = games[i]; if (currentGameToCheck.type == lookingForType && currentGameToCheck.preference == lookingForPreference){ suggestedGames.push(currentGameToCheck); } } return suggestedGames; } /// <summary> /// Returns the value of the checked radio button for the radio button group with the supplied group name. /// </summary> function getRadioButtonSelectedValue(radioButtonGroupName){ //gameInfo is the name of our form object, so the document.gameInfo will give us our form element //and in that object we should have a list of radiobuttons corresponding to the supplied name var radioButtons = document.gameInfo[radioButtonGroupName]; //Iterate through the found buttons and return the value of the selected button if (radioButtons && radioButtons.length){ for (var i = 0; i < radioButtons.length; i++){ if (radioButtons[i].checked) return radioButtons[i].value; } } //If no button was selected, or the radioButtonGroupName was invalid, return null. return null; } /// <summary> /// Reads the selected values and displays suggestions to the user. /// </summary> function suggestGame(){ //The string sent to the method needs to match the name given to the radio button elements in that group. var type = getRadioButtonSelectedValue('type'); var preference = getRadioButtonSelectedValue('preference'); //If both type and preference was selected, alert the user of suggestions found if (type && preference){ var suggestions = getGameSuggestions(type, preference); if (suggestions.length == 0){ alert('No suggestions found for your selections'); } else{ for(var i = 0; i < suggestions.length; i++){ alert('Game suggested: ' + suggestions[i].name); } } } } </script> </head> <body> <fieldset> <legend>Game suggestions</legend> <form name="gameInfo"> <div> <div>Choose game type</div> <input type="radio" name="type" value="fps">FPS</input> <input type="radio" name="type" value="rts">RTS</input> <input type="radio" name="type" value="rpg">RPG</input> </div> <div> <div>Choose preference</div> <input type="radio" name="preference" value="tactical">Tactical</input> <input type="radio" name="preference" value="arcade">Arcade</input> <input type="radio" name="preference" value="offline">Offline</input> </div> <input type="button" value="Suggest game!" onclick="suggestGame();"/> </form> </fieldset> </body> </html>
Monday, March 26, 2012 4:38 AM
Answers
-
User1657234241 posted
Do you need a publish with popup window or automatically? If you want to do it automatically
user has to previously grand stream publish permission.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 26, 2012 6:22 AM -
User1657234241 posted
You can see page source from this page and adapt it for you application:
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 26, 2012 10:25 AM
All replies
-
User1657234241 posted
Do you need a publish with popup window or automatically? If you want to do it automatically
user has to previously grand stream publish permission.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 26, 2012 6:22 AM -
User-308590806 posted
I was thinking with a pop up... say a button within the messegebox. well thats what I had in mind
Monday, March 26, 2012 10:02 AM -
User1657234241 posted
You can see page source from this page and adapt it for you application:
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, March 26, 2012 10:25 AM -
User-308590806 posted
I am going to be brutally honest here.. I don't know where to start with the code above :(. I am at home with c# but anything to do with the web and I am in the dark :(
Monday, March 26, 2012 8:58 PM