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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:28:52+00:00 2026-05-18T08:28:52+00:00

I am trying to: click on the link shown below and have the value

  • 0

I am trying to:

click on the link shown below and have the value passed to an JQUERY $.get (I think it has to be done like that) and this should be made available to a SQL snippet which will include it its WHERE clause.

LINK

$sOutput .= '"<a href=\"#whatever?' .addslashes($aRow['id_cruise']) .'\" class=\"flip\">'.addslashes($aRow['from_country']).'</a>",';

When I click on the link, you see that Flip class. That does open alright a slide pannel within which I have a div that would be populated after a SQL query works with the value sent:

JQUERY SNIPPET

<script type="text/javascript"> 
$(document).ready(function(){
$('a.flip').live('click',function(){
    $(".panel").slideToggle("slow");

  });
});
</script>

As you can see, it uses the LIVE function so that up on clicking indeed activates the slide pannel open. But I need that last bit more, the one that sends the value (of id_cruise). When I hover down the rows, I can see that the value of ID changes, which is great, but however I am not getting to make it passed to the snippet and picked up by the SQL query.

So I can see that in the link, where I write “whatever”, indeed it doesnt matter, as long as it has the # sign. Note that the Link is part of the server processing file, whilst the JQUERY is on the user visible page file, they are in two different pages.

UPDATED FROM HERE, INCLUDING NOW THE CODE FROM JEFF:

The link looks so now:

$sOutput .= '"<a href=\"#id?' .addslashes($aRow['id_cruise']) .'\" class=\"flip\">'.addslashes($aRow['from_country']).'</a>",';

Jeff wisely indicated how there should be a third file which would get the parameter from the second JQUERY snippet, return it and this second would pass it to a third one located just below. This third snippet is the one that forwards it to the DIV box located inside the slide panel.

<script type="text/javascript"> 

$(document).ready(function(){
$('a.flip').live('click',function(){
$(".panel").slideToggle("slow");
      DoSomethingWith(this.id);

     });

});
</script>


 <script type="text/javascript">

function DoSomethingWith(id) {
  $.get("SendIdToDatabase.php", {idCruise: id}, AnotherFunction);
}
function AnotherFunction(str) {
  $("#reviews").html(str);
}
</script>

OTHER CONTRIBUTOR SAID THAT IT COULD BE MERGED AND SIMPLIFIED INTO THIS:

$(function() {
      $('a.flip').live('click',function() {
            $('.panel').slideToggle(slow');
            $('#reviews').load('SendIdToDatabase.php', {idCruise: this.id});
      });
});

SO NOW I CREATE THE PHP CODE (SendIdToDatabase.php) THAT WILL HANDLE THE SQL REQUEST

 <?php


$id_crucero = $_REQUEST['id_cruise']; //this is what I (hopefully) should get from the page
              require ('mysqli_connect.php');

                    $sql ="SELECT description
                        FROM cruises
                        WHERE id_cruise
                        = '".$id_crucero."'";

                        $result = @mysql_query ($sql);

                    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {


                    $reviews = ($row['description']);
                    echo "$reviews";
                    }        

                      ?>

AND FROM HERE IT SHOULD ECHO IT TO THE SECOND AJAX CODE SNIPPET WHICH FORWARDS IT TO THE PANEL (WHICH I HAVE RENAMED TO “REVIEWS” AND IT IS A DIV, NOT AN HTML)

BUT SOME LINK MUST BE BUGGY AS AT SOME POINT THE VALUE IS NOT PASSED OR RECEIVED.

AS OF 1 DECEMBER THE VALUE IS STILL NOT PASSED ON. I HARDCODED SOME TEXT IN THE PHP SCRIPT AND YES, THAT IS SHOWN IN THE DIV BOX INSIDE THE PANEL BUT IT DOES NOT SHOW THE VALUE

  • 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-18T08:28:52+00:00Added an answer on May 18, 2026 at 8:28 am

    I believe what you are looking for is the “this” object. Within the “this” object, you can get the id property. For example:

    <script type="text/javascript"> 
    $(document).ready(function(){
    $('a.flip').live('click',function(){
        $(".panel").slideToggle("slow");
        DoSomethingWith(this.id);
      });
    });
    </script>
    

    Once you have the id, you can then pass it to another script with Ajax for processing:
    For Example:

    <script type="text/javascript">
    function DoSomethingWith(id) {
      $.get("SendIdToDatabase.php", {idCruise: id}, AnotherFunction);
    }
    function AnotherFunction(str) {
      $(".panel").html(str);
    }
    </script>
    

    Check out jQuery Get for documentation on sending “get” Ajax calls.

    You would need to write the php script (SendIdToDatabase.php) to do whatever you wanted with the id. Don’t forget to remove the #Whatever, from the id before using it.

    As for why it needs to be a separate script, you need to understand the “disconnected” nature of http requests. Here are some decent explanations and diagrams.

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

Sidebar

Related Questions

I'm trying to click on a link using jquery. There only appears to be
I'm trying to make a window that closes when you click outside it ,
I am trying to make a div, that when you click it turns into
I am very new to javascript and ajax/jquery and have been working on trying
I'm trying to get the following jquery toggle to work on IE, FF, and
I'm trying to get a jQuery lightbox to load up when a page loads.
I have a link that functions similar to a drop down menu in that
I am trying to have a link appear on mouseover and when clicked, have
Im trying to change images on click similar to what SO does with the
I'm trying to make the case for click-once and smart client development but my

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.