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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T04:31:05+00:00 2026-05-20T04:31:05+00:00

I am using jQuery to load some data inside a div, after posting some

  • 0

I am using jQuery to load some data inside a div, after posting some options. The returned data also contains a dynamically generated form. After the data has loaded, I need to get the form values using getElementById(name), but it does not work (returns null).

I have tried sending and loading the results with .load() and .post()

Example code:

//function to load data
function loadProductPrices(var1)
{
    //#thisProductPrices is the data container
    $('#thisProductPrices').load('filename.php', { 'var1': var1});
}

//function to get element value after previous function has been called 
//(this one is called by a button that is part of the content that has 
//been generated by the previous call) 
function getAndSaveValue(elementID)
{
    var thisValue = document.getElementById(elementID).value; // this returns null (?)
    // after I have the new value I will post and save, using jquery again.
}

The html generated by loadProductPrices() returns a list of items

PriceValue
<input type="text" id="price_productID" value="PriceValue" />
<input type="button" value="save new price" onclick="getAndSaveValue(price_productID)" />
// the above button calls getAndSaveValue, in order to retrieve the new price 
//and save it...
//however it returns null.

Any suggestions? thnx!

  • 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-20T04:31:06+00:00Added an answer on May 20, 2026 at 4:31 am

    There are two ways to fix the problem:

    1. You have to wrap the parameter passed to getAndSaveValue in quotation marks (otherwise you pass the variable price_productID (which is undefined) to the function and not the string):

      onclick="getAndSaveValue('price_productID')"
      //                    ---^            ---^
      
    2. Pass the element directly:

      onclick="getAndSaveValue(this)"
      

      then you have to change the function to:

      function getAndSaveValue(element) {
          var thisValue = element.value;
      }
      

    Side note: At least for element retrieval and traversing, I would use jQuery consistently. In solution #2 it is not necessary, but in #1, you could change your code to:

    onclick="getAndSaveValue('#price_productID')"
    //                     ---^
    

    and

    var thisValue = $(elementId).val();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load some external content using jQuery load function to div on
I'm using the jQuery .load() function to pull in data to populate a div
i am trying to load some data using json and jquery the problem occurs
I am using jQuery load, to load some data from an external file like
I am using jQuery's $.get() to load some content to a div whose id=results
I'm using jQuery to load some content into a lightbox-like div in a web
I'm using jQuery UI Tabs to load some content via Ajax when the user
I have a script on jquery that load some site in iframe using: $(#demo_frame).attr('src',
I have some problem to get the utf-8 string from PHP using jQuery $.load()
I am using the jquery ajax api so load in some content, the code

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.