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 8739713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:59:29+00:00 2026-06-13T10:59:29+00:00

I have some problems when trying to pass some parameters to PHP via JS.

  • 0

I have some problems when trying to pass some parameters to PHP via JS.

Here’s the situation:

HTML:

<form id="numbtns" method="post" action="imphp.php">
  <button id="1" onClick="pass(this.id)">1</button>
  <button id="2" onClick="pass(this.id)">2</button>
  <button id="3" onClick="pass(this.id)">3</button>
  <button id="confirm" onClick="save()">submit</button>
</form>

JS:

pass(clicked_id) {
     var btn = document.getElementById(clicked_id);

     **// I have no idea what to do next to give the ids to the php file.**

     }

save() {
**// I want function save() to collect the parameters from function pass(), and pass      them to 'imphp.php' when submit button is clicked. I'm stuck here.**
}

PHP:

// connection part, let's skip it.

...

$num = $_POST['num'];
$query = sprintf("SELECT id, num FROM tb WHERE num = $num");

I know maybe it’s a quick and stupid question for u, but I cannot figure it out for hours. So… could anyone help me out, I’d be very appreciate that.

Thx in advance.

  • 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-06-13T10:59:30+00:00Added an answer on June 13, 2026 at 10:59 am

    I don’t think you need Javascript for this. All you want to do is post the form to the PHP page, right?

    <form id="numbtns" method="post" action="imphp.php">
      <input type="radio" name="num" value="1" /> 1<br />
      <input type="radio" name="num" value="2" /> 2<br />
      <input type="radio" name="num" value="3" /> 3<br />
      <input type="submit" value="Save" />
    </form>
    

    Using buttons made no sense to me at all, so I changed them to radio buttons. The user will check one, then click the Save button to submit the form.

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

Sidebar

Related Questions

I am trying to pass some parameters to a php file and then load
I'm having some problems trying to perform a query. I have two tables, one
I have been trying to learn Erlang and have been running into some problems
I'm trying to build firefox but I'm having some problems. I currently have Visual
I have this query, which is giving me some problems... I am trying to
I have some problems with the SHA1 hash value of a string. I'm trying
I have some problem in my JDBC code. I am trying to connect through
I have a problem trying to design some generic storage.. Basically I have the
I'm trying to get a regexp to solve the next problem: I have some
Gday All, I have a baffling problem whilst trying to insert some chinese characters

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.