Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7686821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:34:00+00:00 2026-05-31T19:34:00+00:00

I have some sort of a jquery chat at one specific PHP page. Of

  • 0

I have some sort of a jquery chat at one specific PHP page. Of course, bellow that chat area there is an input field (jquery form), and after you click on a label id button, jQuery gets your words, username, stores data into MySql and reloads chat again. Funny lightweight and neat. Reason no1 why you must love jquery.

Anyway, most important to say, that “button” is not submit button – its a “label id” button.

Thats quite okay, but when you get hot into that chat, and you suddenly press enter, instead you click on a label button – PHP page just refreshes and does nothing with data what makes everyone crazy.

So, any hot tip how to send keyboard enter as a click on that label id button?


UPDATE:

<form id="chav_box_in" style="padding:0px;margin:0px;" action="" method="post">
      <div class="chav_level" valign="top"><input type="hidden" id="chav_in" name="chav_in" value="'.$categoryid.'" />
      ' . $lg['your_nick'] . ':&nbsp;&nbsp;';
    if($userinfo['loggedin'])
    {
        if($getnamen = $DB->query_first("SELECT userid, jur_name FROM " . TABLE_PREFIX . "users WHERE userid = '".$userinfo['userid']."'"))
        {
        echo '<input type="hidden" id="chav_username" name="chav_username" value="'.$getnamen['jur_name'].'" /><span class="chav_name">'.$getnamen['jur_name'].'</span>';
        }
        else
        {
    echo '<input type="hidden" id="chav_username" name="chav_username" value="'.$getnamen['userid'].'" /><span class="chav_name">Registered undefined ('.$getnamen['userid'].')</span>';
        }
    echo '<input type="hidden" id="chav_lag" name="chav_lag" value="1" />';
    }

    else // unergs
    {
        if($nemere) //cookieid
        {
        echo '<input type="hidden" id="chav_username" name="chav_username" value="'.$nemere.'" /><span class="chav_name">'.$nemere.'</span>';
        }
        else   //nov upisivac
        {
        echo '<input type="text" size="' . $inputsize . '" id="chav_username" name="chav_username" value="" />';
        }
    }

echo '&nbsp;&nbsp;' . $lg['occ_place'] . ':&nbsp;';

// ##########
    if($categoryid == 6)
    {
    echo '<input type="text" size="' . $inputsize . '" id="chav_sub" name="chav_sub" value="" /></div>';
    }
    else
    {
    echo '<input type="hidden" id="chav_sub" name="chav_sub" value="'.$url_places_name.'" /><span class="chav_name">'.$url_places_name.'</span></div>';
    }


    echo '<div class="chav_level">' . $lg['chav_input'] . '&nbsp;&nbsp;<input type="text" size="' . ($inputsize*5) . '" id="wm1" name="wm1" value="" />
     &nbsp;<label id="shareButton1" class="enter" style="display:inline;float:right;">' . $lg['publish'] . '</label></div>';


    echo '</form>

Now, when I enter something in that input field and press enter, page refreshes.. no mind for a mess im cleaning it out.. AND query

$(function () {
$('chav_box_in').keypress(function(e) { // Attach the form handler to the keypress event
    if (e.keyCode == 13) { // If the the enter key was pressed.
        $('#shareButton1').click(); // Trigger the button(elementId) click event.
        return e.preventDefault(); // Prevent the form submit.
    }
});
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:34:02+00:00Added an answer on May 31, 2026 at 7:34 pm
    $('form').keypress(function(e) { // Attach the form handler to the keypress event
        if (e.keyCode == 13) { // If the the enter key was pressed.
            $('#elementId').click(); // Trigger the button(elementId) click event.
            return e.preventDefault(); // Prevent the form submit.
        }
    }​);​
    

    Now you can get hot in the chat, and enter will work for you just like clicking the button… Which I think should work this way anyway.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

One of the huge benefits in languages that have some sort of reflection/introspecition is
In my limited experience, I've been on several projects that have had some sort
I have found that I often have to implement some sort of a scheduler
I have some old code that uses qsort to sort an MFC CArray of
I have some PHP code which allows me to sort a column into ascending
If for example, I have some jQuery doing something simple like: $(div).fadeIn('fast'); $(div).html('Foo'); That
I have some HTML that looks like this: <ul class=toggleList> <li><input type=checkbox name=toggleCbx1 id=toggleCbx1
I'm looking for some sort of jquery plugin (or even plain javascript) that can
I have some very simple forms that will send the user to a specific
I have some divs that when the page loads are populated with images of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.