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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:22:24+00:00 2026-05-26T15:22:24+00:00

I have some data from database coming out in a loop. Each of these

  • 0

I have some data from database coming out in a loop. Each of these records have a button (hyperlink actually) called “Redeem”. A user can click on this button to confirm his selection. If he clicks yes, then another dialog will show up asking him to click on the “Print” button or cancel printing. If he clicks “Print”, then the variables/data belonging to this record, should be sent over to a div with ID: “printing_div”. These variables will be used to query the database, retrieve certain results and then echo the result so that the user can print this data.

For illustration, consider below:

Record 1 ----- <a href="#" id="r1">Redeem</a>
Record 2 ----- <a href="#" id="r2">Redeem</a>
Record 3 ----- <a href="#" id="r3">Redeem</a>
.
...

Say if user clicks on the Redeem button belonging to the 2nd Record, then:
1. A dialog box pops up asking him to confirm if he wants to Redeem. Clickable buttons are “Yes” and “No”. If No is pressed, the dialog box disappears. If Yes is clicked, then it launches another dialog box which says: Are you sure you want to print now? Clickable buttons are “Print Now” and “Cancel Print”. If “Cancel Print” is clicked, the recent dialog box is closed. If “Print Now” is clicked, then the id of that hyperlink that was clicked (i.e ‘r2’) should be passed as a value to a div with ID ‘printing_div’. This r2 will be used to query database such as:

$query = "SELECT FROM table WHERE col = 'r2' ";
$row = mysql_fetch_array($query);

echo $row[0].$row[1];

The above echo’ed data will be printed.

So in my case, I am unable to pass the id (i.e r2) to the printing_div, so that I can query the database. How can I do this?

All help is appreciated. Thank you.

  • 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-26T15:22:25+00:00Added an answer on May 26, 2026 at 3:22 pm

    So given your links, like so:

    <div id="redemption">
       <a href="#" id="r1">Redeem</a>
       <a href="#" id="r2">Redeem</a>
       <a href="#" id="r3">Redeem</a>
    </div>
    

    And a div you mentioned for printing:

    <div id="printing_div"></div>
    

    You can do like jfriend00 mentioned above:

    $("#redemption a").click(function() {
       var id = this.id;
    
       // Assign the id to a custom attribute called data-id
       $("#printing_div").attr("data-id", id);
    
       return false;
    });
    

    And then of course you can retrieve the new attribute in any AJAX call you send back to the server by:

    var id = $("#printing_div").attr("data-id");
    

    Hope that helps.

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

Sidebar

Related Questions

So I have some data that's coming back from a database query, and the
We have recently moved some data from an SQL Database instance to another one
I have some existing code that retrieves data from a database using ADO.NET that
If have a piece of code that gets some data from a sql database
I have a php script which accesses a MSSQL2005 database, reads some data from
I have a live database that had some data deleted from it and I
I have some data, yes, data. This data came from a MySQL query and
I have some data that comes regularily as a dump from a data souce
We have some C# code that reads data from a text file using a
i have a task - i must grab some data from the URL. the

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.