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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T23:08:53+00:00 2026-06-01T23:08:53+00:00

I have been struggling with this for days. This works, but does not pass

  • 0

I have been struggling with this for days. This works, but does not pass the correct variable to the page ( testMap.php ). I use data from my DB and hovering over the link does show the correct variables in the URL, but for whatever reason jquery is always grabbing the first variable in the loop. Any suggestions?

<?php
    $myname = $_SESSION['username'];
    global $database;
    $stmt = $database->connection->query("SELECT * FROM ".TBL_FLIGHTS." WHERE username='$myname'");

        while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){
            $date       = $row['date'];
                    $starting   = $row['starting'];
                    $ending     = $row['ending'];
                    $route      = $row['route'];
                  echo "<a class=\"route\" href=\"start=$starting&end=$ending\"><p class=\"pBlue\">$date - $starting - $ending - $route</p></a>";
                  ?>
        <div id="start" style="visibility:hidden"><?php echo $starting; ?></div>
        <div id="end" style="visibility:hidden"><?php echo $ending; ?></div>
        <?
    }

    ?>


<script type="text/javascript">
$(document).ready(function() {
    var start = $('#start').text();
    var end = $('#end').text();

    $(function() {
      $(".route").click(function(evt) {
         $("#mymap_canvas").load("testMap.php?start="+start+"&end="+end )
         evt.preventDefault();
      })
    })

});
</script>
  • 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-01T23:08:55+00:00Added an answer on June 1, 2026 at 11:08 pm

    Indeed; you need to capture the start and end values within the click event and choose the start and end values that are nearby to the route that was clicked.

    Possibly what you want:

    $(".route").click(function(evt) {
        var start = $(this).siblings(".start").text();
        var end = $(this).siblings(".end").text();
        $("#mymap_canvas").load("testMap.php?start="+start+"&end="+end )
        evt.preventDefault();
    }); // I believe you are missing a semicolon here and at the end, too
    

    But unless I’m missing something you could really just build that href via php (like you already are except complete it with the full path and query string) and then execute it like this:

    $(".route").click(function(evt) {
        // Load the href of the route anchor into 'mymap_canvas'
        $("#mymap_canvas").load($(this).attr("href"));
        event.preventDefault();
        return false; // Prevent the normal click behavior
    });
    

    No more hidden start and end! But be sure to update your original anchor tag to look like this:

    <a class=\"route\" href=\"testMap.php?start={$starting}&end={$ending}\">...</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

sorry to post this but have been struggling now for 8 days and really
So I've been struggling with this for a couple days now. I have a
I have been struggling with getting this to work for a number of days
I have been struggling with this problem for a few days now and I
I have been struggling with this issue for the past couple days: I have
I have been struggling with this for several days now and I ran out
i have been struggling with this for a few days. I have a total
I have been struggling with this for days. I have a form that's a
I have been struggling with this for 2 days. Since I added text labels
I have been struggling with this for a few days. I need somebody to

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.