Note that there are some explanatory texts on larger screens.

plurals
  1. POPosting to a Facebook wall using a single function
    primarykey
    data
    text
    <p><strong>Overview:</strong></p> <p>I got a website that has sentences that people can post to Facebook, but in each sentence there are input boxes, which people can change the default value. Kind of like a digital "Mad Lib". Each line has a button which will post that line to Facebook.</p> <p><strong>Help with:</strong></p> <p>Having a single function to post the data of the button being pressed to Facebook. I could just name the function differently and add the variables, but it defeats the purpose of a function.</p> <p><strong>HTML</strong></p> <pre><code>&lt;div id="post1"&gt; &lt;span&gt;I like&lt;/span&gt; &lt;input name="post1_1" value="Tom" type="text" id="post1_1" /&gt; &lt;span&gt;I think she is&lt;/span&gt;&lt;input name="post1_2" value="Nice" type="text" id="post1_2" /&gt; &lt;a href="javascript:Post(post1)"&gt;POST NOW&lt;/a&gt; &lt;/div&gt; &lt;div id="post2"&gt; &lt;span&gt;My website is&lt;/span&gt; &lt;input name="post2_1" value="Great" type="text" id="post2_1" /&gt; &lt;a href="javascript:Post(post2)"&gt;POST NOW&lt;/a&gt; &lt;/div&gt; </code></pre> <p><strong>SCRIPT</strong></p> <pre><code>function postonwall(post1, post2) { var post1_1 = null; var post1_2 = null; var post2_2 = null; var post2_3 = null; var post1_1 = $("#post1_1").val(); var post1 = "I like" + post1_1 + ". I think she is" + post1_2; var post2_1 = $('#post2_1').val(); var post2 = "My website is" + post2_1; FB.api('/me/feed', 'post', { message: post1, message: post2 }, function(response) { if (!response || response.error) { alert('Oops! User Denied Access'); } else { alert('Success: Content Published'); } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload