php form textarea text on facebook share when click on button
Asked Answered
S

0

0

i have form and in form text area and submit button
when i click on submit button and share data taken homepage banner and text not textarea text

<form id="facebook-form" method="post">
<ul class="form-list">
    <li>
        <label for="facebook-content"><?php echo $this->__("Post on Facebook") ?>:</label>
        <div class="input-box">
            <textarea id="affiliate-facebook-content" class="required-entry"><?php echo $this->getDefaultSharingContent() ?></textarea>
        </div>
    </li>
</ul>
<div class="buttons-set">
    <button type="button" class="button" title="<?php echo $this->__('Post on Facebook') ?>" onclick="postOnFacebook();">
        <span><span><?php echo $this->__('Post on Facebook') ?></span></span>
    </button>
</div>

my javascript code:

function postOnFacebook() {
    if (facebookForm.validator.validate()){
        var params = Form.serializeElements($('facebook-form').select('input, select, textarea'));
        var url = '<?php echo $this->getUrl("affiliates/refer/test") ?>';

        var message = $('facebook-content').value
                            // calling the API ...
        if(message) {
            // alert(message);
            var obj = {
                method: 'feed',
                link: $('personal_affiliate_url').href,
                description: message
            };

            function callback(response) {
                if (response && response.post_id) {
                    $('affiliate-facebook-msg').show();
                }
                else{
                    alert('This message hasn\'t been posted successfully!');
                }
            }
            FB.ui(obj, callback);
        }
    }
}

Any help would be appreciated.

Thanks.

Salcido answered 27/8, 2019 at 18:26 Comment(5)
Do you have any errors in the browser console?Canicula
no any error...Salcido
I'm not sure if .select is what you want. I was able to make it work when adding names to the fields.Canicula
This might be more of what your looking for #12863101Canicula
@JasonK please update your answer in below answerSalcido

© 2022 - 2024 — McMap. All rights reserved.