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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:56:19+00:00 2026-05-25T02:56:19+00:00

Ok guys here’s my dilemma, I just need some basic help… soo if I

  • 0

Ok guys here’s my dilemma, I just need some basic help… soo

if I have a set of variable say…

$h1 = ""
$h2 = ""
$h3 = ""
$h4 = ""

and i’m using a data attribute on the element, how can I use the number I pull to put into a string that acts as the variable name. so in the function below, you click a class item, it get’s the value from the data attribute then I need to populate the #work_hold div with the corresponding variable. If I do what I have below, the $tme acts as a string and doesnt work. any ideas?

$(".box").click(function(){
var atr = $(this).attr("data-bsel"); 
$tme = '$h'+atr;
$('#work_hold').html($tme);
  });
  • 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-25T02:56:19+00:00Added an answer on May 25, 2026 at 2:56 am

    You want an array:

    var h = [];
    h[0] = ...;
    h[1] = ...;
    h[2] = ...;
    ...
    
    $tme = h[atr];
    

    You do NOT want to build variables dynamically. That just leads to utterly icomprehensible and impossible to debug code.

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

Sidebar

Related Questions

Guys i need some help here , im getting this error here at the
Hi guys I was hoping from some help here, please. I have a INSERT
With the help of some of the guys here I have some regex to
Pretty Basic one here guys. I have a View which holds 2 textfields for
I have some guys here who have code that needs to be compiled with
Rather basic question here guys. Basically I have code like this: public SuperPanel() {
Hey guys I have a little issue here. I have a panel where I
Hey Guys, here is my code for this, the only help i get from
Sorrry guys, I'm stuck here. I have a few grids, I also have CollectionViewSource
First I want to thank you guys here, because your posts have gotten me

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.