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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:40:45+00:00 2026-06-07T19:40:45+00:00

I am fairly new to js and jquery. I basically want to be able

  • 0

I am fairly new to js and jquery. I basically want to be able to change the table and id variables from an onClick event or something appended to the <a> this way I can modify the variables with php later on. This is just proof of concept, and doesnt seem to be working since I made modifications. Is there a way that I can pass variables from the a to the function?

OVERALL GOAL: I want to have an inline onclick that will pass id and table names from loadMe to the function and display table_render.php?id=someid&table=sometable in the dialog box.

  <script>
    $(function loadMe(table, id) {
        $( "#dialog-view" ).dialog({
            autoOpen: false,
            height: 600,
            width: 700,
            modal: true,
            buttons: {
                Cancel: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
        $( "#create-view" ).click(function() {
            $( "#dialog-view" ).load("table_render.php?id=" + id + "&table=" + table + "").dialog("open");
        });
    });
    </script>
    <a href="" id="create-view" onClick="loadMe(testimonials,1)">Some text</a>
    <div id="dialog-view" title="">
    </div>
  • 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-07T19:40:47+00:00Added an answer on June 7, 2026 at 7:40 pm

    You are hooking up the event twice, once via onclick and once via jQuery. You need to pick one.

    If you pick the jQuery way (recommended) you’re going to get the jQuery arguments (which is just one arg, event). However, jQuery will set this to the element that triggered the event (in this case, your A tag). You can use that to get data off of the A tag.

    For instance, if you wanted the ID of the A that got clicked, you could do this in your handler:

    var clickedId = $(this).attr('id');
    

    If you want to store some arbitrary info (eg. “tableName”) for each A tag, you can either use the HTML 5 data attributes (preferable), or just make up your own attributes (which will work, but is “bad form”). For instance:

    <a tableName='testimonials'>
    
    var clickedFoo = $(this).attr('tableName');
    

    or (a little better):

    <a data-tableName='5'>
    
    var clickedTableName = $(this).attr('data-tableName');
    // Also, I believe this would work:
    var clickedTableName = $(this).data('tableName');
    

    * EDIT *

    Just to try and clarify a little further, the basic overall idea is this:

    1) You write out your A tags to the page, via PHP

    1A) As you write them out, you put whatever data is specific to them on the A tag, in the form of an attribute or attributes (eg. id='foo' data-bar='baz').

    2) You also write out some Javascript code that says “hey, whenever an A tag gets clicked, run this function”

    3) Inside the function that you hooked up to the A tag’s click event, you use the this variable (which points to the A tag itself) to get the data (the “variables”) that you need

    3A) For instance, you could use the JQuery “attr” method: $(this).attr('id')

    4) Profit! (or at least do something useful with the data you just got)

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

Sidebar

Related Questions

I fairly new to JQuery and perhaps trying to achieve something that might be
I'm fairly new to jquery and struggling with something that should be fairly simple.
I'm fairly new to jQuery, and think I might be making something harder than
I am fairly new to jQuery and I have this overlay window that pops
I'm fairly new to jQuery and I'm using the script below. Basically it uses
I am fairly new to jQuery and I wanted to ask a question. Basically
im still fairly new to jquery and i got this slideToggle container, but now
I'm fairly new to jQuery and I'm having trouble with an animation that I'd
I'm fairly new to jQuery and I've been looking for a decent free datepicker
I'm fairly new to JQuery and for some reason I can't get the currently

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.