Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Problem with android and "jumping" in <input textarea

JamesH.

New Coder
we have a problem with newer devices posting comments in the news form with google chrome. If the news is just one everything works fine when you press enter with your phone, but when there are several news and when you press enter just start jumping to the latest news and it only works then. I think the problem is in javascript, so i want to ask you for help. Thanks.

This is javascript;

HTML:
newsReply = function(event, id, item) {
    if(event.keyCode == 13 && event.shiftKey == 0){
        var content = $(item).val();
        var replyTo = id;
        if (/^\s+$/.test(content) || content == ''){
            return false;
        }
        if(content.length > 1000){
            alert("text is too long");
        }
        else {
            $(item).val('');
            if(repNews == 0){
                repNews = 1;
                $.ajax({
                    url: "system/action_news.php",
                    type: "post",
                    cache: false,
                    dataType: 'json',
                    data: {
                        content: content,
                        reply_news: replyTo,
                        token: utk
                    },
                    success: function(response){
                        if(response.code == 1) {
                            $('.ncmtbox'+replyTo).prepend(response.data);
                            nrepCount(id, response.total);
                            repNews = 0;
                        }
                        else {
                            repNews = 0;
                            return false;
                        }
                    },
                    error: function(){
                        repNews = 0;
                        return false;
                    }
                });
            }
            else {
                return false;
            }
        }
    }
    else {
        return false;
    }
}

Our html;

HTML:
<div class="tpad10 reply_post">
            <input onkeydown="newsReply(event, <?php echo $boom['id']; ?>, this);" maxlength="500" placeholder="<?php echo $lang['comment_here']; ?>" class="add_comment full_input">
        </div>
 
Back
Top Bottom