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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:45:51+00:00 2026-06-12T17:45:51+00:00

I am trying to build a db driven web site in which the user

  • 0

I am trying to build a db driven web site in which the user selects from a drop down menu a
value and some Information from a database are returned. I use an ajax post cause i dont want the page to get refreshed:

$("#button").click(function(){ 
   var datastr = ($('#act').val());
   var datastr1 = ($('#loc').val());

   $.ajax({
      type:'POST',
      url:'activities_code.php',
      data: {datastr:datastr, datastr1:datastr1},
      success:function(response){
                $("#msg").html(response);                       
            } });});  

In the url parameter I have the following php file (this is a part of the php file):

 $query = "SELECT PK,title,Information from activities where Activities='$category'";
    $result = mysqli_query($dbcon, $query) or die('no available data');

    echo "<table>";
$num_results = 0;
$t = 0; //title counter for the id of each title
while ($row=mysqli_fetch_array($result, MYSQLI_ASSOC)) {
     // Here the columns of title and information are printed
     echo "<tr><td>";
     echo "<a href='test.php'  id=\"t\".$t onClick=\"test()\" target=\"_new\" >".$row['title']."</a>"; 
     echo "<br>";
     echo  $x = $row['PK'];
     echo "</td></tr>";


     echo "<tr><td>";
     echo $row['Information'];
     echo "</td></tr>";
// Here I sum up the number of the results
     $num_results=$num_results+1;   
     $t = $t+1;      
 }

}

As you can see, I have a while loop in which I echo each time a link with an id:

"<a href='test.php'  id=\"t\".$t onClick=\"test()\" target=\"_new\" >".$row['title']."</a>";

What I want to do is to use this id of each link later in my code by doing something like this:

  document.getElementById("t1").value

My question is, how can I return this id’s to the client side? I think I should write something in the success function but I have no idea what.
If you dont understand some part of the code or I didn’t explain everything clear, please ask me.
Thanks
D.

This is what I get when I alert(response) in the success function.

<!DOCTYPE HTML>




       <table id="container"><tr><td><a href='test.php' id="t0" target="_new"   class='pickanchor'>Rafting in Voidomatis</a><br>1</td></tr><tr><td>
      <img src="m.jpg" class="textwrap" height="120px" width="120px">
      <p style="text-align:left;">Our experienced rafting instructors will show you the best way to enjoy Voidomatis, the river with the most clear waters inSouth Europe. You can also cross the Vikos Gorge by following Voidomatis river in an attractive one and a half hour   long walk. Alternatively you can ask for the more demanding Aoos river rafting.</p>
     <br>
     <br>
     <hr></td></tr><tr><td><a href='test.php' id="t1" target="_new" class='pickanchor'>Rafting   in Lousios</a><br>4</td></tr><tr><td><img src="raf.jpg" class="textwrap" height="120" width="120">
     <p>You will be surprised to know that Greece hides numerous, densely vegetated rivers offering amazing rafting opportunities. In the whole mainland, there is a company base awaiting you, for an amazing � off the beaten track experience!</p>
     <br>
     <br>
     <br>
     <hr></td></tr><div id="r2" align="center" id="result_2">2 results for rafting were found!        
     </div></table>  <!-- End of PHP code-->
  • 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-12T17:45:52+00:00Added an answer on June 12, 2026 at 5:45 pm

    First, There is problem with ID of your anchor tag. here is correction

    "<a href='test.php'  id=\"t".$t."\" onClick=\"test()\" target=\"_new\" >".$row['title']."</a>";
    

    Second, Give id to your table like

    <table id="container">
    

    Third, give class to your anchor tag.

    "<a href='test.php' class='pickanchor'  id=\"t.$t\" onClick=\"test()\" target=\"_new\" >".$row['title']."</a>";
    

    Now write following code into your success handle after .html() statement

    NEW EDIT

    $("a.pickanchor").each(function(i){
    
       alert(this.id);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm essentially trying to do the following on a Java/JSP-driven web site: User supplies
I'm trying build a method which returns the shortest path from one node to
from reading some links on SO, came across 'playframework' to build java web app.
I am trying to build a Google Maps-driven web application that can display a
I'm new to ember and trying to build a Ember driven web application. I've
I was trying Build For Archiving application (from Titanium Mobile) with xCode 4.4, but
I'm trying build an App Engine connected Android application and am having some problems
I would like to build a TabControl in Silverlight which is driven by a
As part of a web app i am trying to build a registration process.
They don't have setMnemonic(), as Buttons do. I'm trying to build some automated UI

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.