Get dynamic link's name with onClick?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Speedy
    New Member
    • Aug 2006
    • 6

    #1

    Get dynamic link's name with onClick?

    Hi all,
    I run a query in PHP on an existing database and convert resulting records (OrderNumbers) into hyperlinks. This spits out a number of results so the user can click any of the links. I would like to be able to click on the link and load the link's name into variable, so I can run another query using this variable later on. Or really just load the link's name into a hidden form field, whatever.

    E.g. how can you? <a href="javascrip t:void(0)" onclick="Get the 'test' value and load it into variable or hidden form field?">test</a>
    Below is the code generating links.

    [PHP]
    $rs=odbc_exec($ conn,$sql);
    if (!$rs)
    {exit("Error in SQL");}
    echo "<table><tr >";
    echo "<th>Order Numbers Found:</th>";
    "<th>Total Qty</th></tr>";
    while (odbc_fetch_row ($rs))
    {
    $orderno=odbc_r esult($rs,"Orde rNo");
    $qty=odbc_resul t($rs,"BuyQty") ;
    echo "<tr><td>". "<a href=\"$orderno \">$orderno</a>" . "</td>";
    echo "<td>$qty</td></tr>";}[/PHP]

    Thanks
    Speedy
  • Speedy
    New Member
    • Aug 2006
    • 6

    #2
    OK after reading quite a few articles about this issue I think I can answer myself and say it is most probably not possible to do it the way I want to.

    INSTEAD:
    Could you please help me with using the existing code and load the OrderNumbers into an option box on the form?

    Thank you
    Speedy

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      Must be something like this, I presume?

      [PHP] echo '<select name="myselect" >';
      while (odbc_fetch_row ($rs)) {
      $orderno=odbc_r esult($rs,"Orde rNo");
      $qty=odbc_resul t($rs,"BuyQty") ;
      echo "<option value='$orderno '>$orderno</option>";
      }
      echo '</select>';
      [/PHP]

      Ronald :cool:

      Comment

      • Speedy
        New Member
        • Aug 2006
        • 6

        #4
        Hi ronverdonk,
        thanks for your reply. I figured how to load it into the option box already, but another user "iam_clint" helped me to use my preferred solution using the 'href's' attribute 'name'.
        I then use this to run the detailed query and display details.

        [PHP]echo "<a href=\"order_de tail.php?name=$ OrderNumber\">$ OrderNumber</a>";[/PHP]

        Speedy
        Last edited by Speedy; Aug 22 '06, 09:37 AM. Reason: Misspelled member's name

        Comment

        Working...