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

  • Home
  • SEARCH
  • 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 8841843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:49:11+00:00 2026-06-14T10:49:11+00:00

I want to pass a value to a Jquery function. Below is the Javascript

  • 0

I want to pass a value to a Jquery function.
Below is the Javascript sample code. I want to convert this javascript function to a jquery function. How can I pass the state name into a jquery onclick function?

<a onclick="showState('state_name')">ADD STATE </a>

 function showState(state_name){
 openbox_state(state_name);
 }

please help me.

  • 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-14T10:49:12+00:00Added an answer on June 14, 2026 at 10:49 am

    You don’t really make it clear whether you have a series of anchors to add different states, or…?

    If you do, you can do something like this to record the appropriate state name for each link:

    <a data-stateName="state_name">ADD STATE </a>
    

    And then in JS, with jQuery:

    $(document).ready(function() {
        $("a[data-stateName]").click(function() {
            openbox_state( $(this).attr("data-stateName") );
        });
    });
    

    This removes the inline JavaScript from your html, and then uses jQuery to bind a click handler only to those <a> elements that have a data-stateName attribute. The handler then gets the value of that attribute to pass to the openbox_state() function.

    The document ready handler ensures that the anchor click binding doesn’t happen until the document actually is ready, i.e., after the elements have been parsed and can be accessed from JS. (You don’t need a ready handler if you put your JS in a script block at the end of the body element.)

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

Sidebar

Related Questions

I have this snippet of code below. I want to pass the value of
On loading the page I want to pass a value to my javascript function
I want to pass a datetime value into my python script on the command
I want to pass selected value on invoice.php file using jQuery. After sending value
I have the below jquery function $(function(){ $(select#rooms).change(function(){ $.getJSON(/admin/select.php,{id: $(this).val(), ajax: 'true'}, function(j){ var
How can I pass the values of a jQuery callback function to a PHP
<script type=text/javascript> var CountryVal; var StateVal; $(document).ready(function(){ $('#ItemCountry').change(function(){ CountryVal = this.value; // value of
<script type=text/javascript> var CountryVal; var StateVal; $(document).ready(function(){ $('#ItemCountry').change(function(){ CountryVal = this.value; // value of
quick question here. Normally, using JQuery, if I want to pass the value from
What I want is to pass the value of txtComments from View (using jquery/ajax)

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.