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

  • Home
  • SEARCH
  • 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 6383267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:37:41+00:00 2026-05-25T02:37:41+00:00

My Form looks like this: <body> <form id=myForm method=post> <label>id:</label> <input type=text name=id id=id

  • 0

My Form looks like this:

<body>
<form id="myForm" method="post">
<label>id:</label> 
<input type="text" name="id" id="id" size="50"/>
<div id="hidden" style="display: none;">
<label>Name:</label>
<input type="text" name="name" size="50"/><br/>
<input type="button" id="button2" value="Update" size="25" /> <br/>
</div> 
<input type="button" id="button1" value ="Get Info" onclick="document.getElementById('hidden').style.display = ''; this.style.display = 'none'" size="25"/>  

I have JS that looks like this

$(document).ready(function(){  
$("#button1").click(function(){
    $.post(
        'xxx.php',
        { id: $('input[name="id"]', '#myForm').val() },
        function(json) { 

            if (json.abc === 'no'){
             alert('does not exist');   
            }
            else{
            $("input[name='name']").val(json.name);
            }},
        "json"
    );
});

$("#button2").click(function(){
    $('form#myForm').attr({action: "xxx1.php"});
    $('form#myForm').submit();
});
});

The problem is that the user can only submit this form by clicking on the submit button. Any ideas on how i can adjust the js so that the enter button(on keyboard) also submits the form?

Note: there are two submit buttons both are interlinked.

  • 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-25T02:37:42+00:00Added an answer on May 25, 2026 at 2:37 am

    You could give your input element an id, for easier retrieval:

    <input id="txtName" type="text" name="name" size="50"/><br/>
    

    Then you may bind your function to the keypress event:

    $('#txtName').keypress(function (e) {
      if (e.which == 13) {
        $("#button1").click()
      }
    });
    

    Or, for a general case, you may want to just bind the function to every text box of the form:

    $('#myForm input:text').keypress(function (e) {
      if (e.which == 13) {
        $("#button1").click()
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that looks like the following: <form id=MyForm name=MyForm method=post action=index.php> <input
y0 c0derz! My formula looks like this: <form method=post action=index.php?sida=upl enctype=multipart/form-data name=myform> <input type=file
I have a php page like this : <html> <body> <form method=post action=catch_combo.php> <select
I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In
I have a form that looks kind of like this: <div> <div class=contact> <h1>Person's
I have a form in a .html files where input/select box looks like this
My form looks like: <%= form_for [:admin, @post] do |f|%> <div style=width:660px;> <%= f.text_field
I have a webpage that looks like: <html> <head> <title>Hi</title> </head> <body> <form name=mainForm
I have a simple form that looks like so <% remote_form_for post, :url =>
I want to do an HTTP POST that looks like an HMTL form posted

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.