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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:27:36+00:00 2026-06-16T19:27:36+00:00

Mega noob here so excuse me if this is a silly question or if

  • 0

Mega noob here so excuse me if this is a silly question or if it doesn’t make any sense.

I have a li list which I create dynamically from a mySQL database. The code for this looks like this:

var resultCount = 0;
var mxKey = $.now();

$.get("\\php\\phpGenre.php?mxKey"+mxKey, function(genreData){

    jsonResults = JSON.parse(genreData);

    while (resultCount<jsonResults.length){
        var genreName = jsonResults[resultCount]['genre_name'];
            $('#genreList').append('<li><a href="#" onclick="searchGenres(' + genreName + ');return false"><span>' + genreName + '</span></a></li>');
                resultCount++;
    }

});

When I create my list I also need to be able to add an onClick event which calls a function… this function uses the list name as a value and is generated via the variable genreName. My list gets created ok but the onClick event doesn’t work and keeps returning:

SCRIPT5009: 'Documentary' is undefined

or another example would be:

SCRIPT5009: 'Fantasy' is undefined 

Where ‘Documentary’ and ‘Fantasy’ are the genreName.

So my question is how can I include an onClick event to each list item which will use the genreName as the value?

If I hard code the list it works fine:

<ul><li><a href="#" onclick="searchGenres('action');return false"><span>Still To Do...</span></a></li></ul>

Thanks…. sorry once again for my poor coding knowledge.

  • 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-16T19:27:39+00:00Added an answer on June 16, 2026 at 7:27 pm

    youu need to escape ' your genrename since u want to send it as string.
    try this

    $('#genreList').append('<li><a href="#" onclick="searchGenres(\'' + genreName + '\');return false"><span>' + genreName + '</span></a></li>');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a working Joomla extension (YT Mega menu). I want to make some
i found this mega dropdown menu using CSS3. this worked perfectly but i have
I'm working on building mega menu. I have trouble when arrange div. Here's the
Hyper-mega-noob-question, i've been racking my brain over how to add next/ previous buttons to
I have a simple sketch on my Seeeduino Mega 1.22 which just displays the
I have some mega menu style menus on a site I maintain. These are
IAPX88 can deal with 1 mega byte memory(20 bit addressing), now my question is
I have the following markup that is used to produce a pop-up style mega-menu
First up, sorry for the mega-posting of code but... I have the following DB
I have model like this: scope :search_posts, lambda { |query| mega_posts.where( title LIKE ?

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.