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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:38:04+00:00 2026-06-05T00:38:04+00:00

In my code I’m creating a product list dynamically using PHP (see image) and

  • 0

In my code I’m creating a product list dynamically using PHP(see image) and the currosponding labels and image paths are stored into hidden fields(created dynamically using PHP) now on document.ready() method i set the first list item’s imagepath to img's src and its remarks to label remarks using first hidden fields for remark and imagepath.

and on listitem click i want to change it my function set these values to img and label rightly(checked using alerts) but when function ends it set the image src and remarks innertext to default that is set on document.ready() method

now my question is can i prevent the document.ready() to be executed next time on javascript function call

My View :
As the images are reloaded so the page rendering is done again so the document.ready is called again and set these values again to default.

Note :

My page is not reloading any time only images and labels are being changed

The listshown in image is just one group other group is also created dynamically .

Product list with remark and images

server side code in PHP

<?php 
for($j=0;$j<count($productstr);$j++) { 
$valuerem = $productstr[$j]["pcode"];
$idrem  = "rem".$j.$grp;
$valueimg =$productstr[$j]["imgpath"];
$idimg = "img".$j.$grp;
echo "<input type='hidden' value='$valuerem' id='$idrem' />" ;
echo "<input type='hidden' value='$valueimg' id='$idimg' />" ;
}?>
<script>   
   $(document).ready(function() {
    idrv < ? PHP echo $grp; ? > = 'rem0<?PHP echo $grp; ?>';
    idmv < ? PHP echo $grp; ? > = 'img0<?PHP echo $grp; ?>';
    $('#txt<?PHP echo $grp; ?>').text(document.getElementById(idrv < ? PHP echo $grp; ? ).value);
    alert($('#txt<?PHP echo $grp; ?>').text());
    $('#img<?PHP echo $grp; ?>').attr('src', document.getElementById(idmv < ? PHP echo $grp; ? > ).value);
    alert($('#img<?PHP echo $grp; ?>').attr('src'));
  });

  function Change(id) {
    idrv < ? PHP echo $grp; ? > = 'rem' + id;
    idmv < ? PHP echo $grp; ? > = 'img' + id;
    $('#txt<?PHP echo $grp; ?>').text(document.getElementById(idrv < ? PHP echo $grp; ? > ).value);
    alert($('#txt<?PHP echo $grp; ?>').text());
    $('#img<?PHP echo $grp; ?>').attr('src', document.getElementById(idmv < ? PHP echo $grp; ? > ).value);
    alert($('#img<?PHP echo $grp; ?>').attr('src'));
    return true;
  }​
</script>

alerts are used just to test the values

the code that are being generated at client browser

 <tr>
    <td width="220px" valign="top" align="left">
    <input id="YN" type="hidden" value="true">
    <input id="rem00" type="hidden" value="SPL FUNNEL 1">
    <input id="img00" type="hidden" value="adminpanel/product_images/4f8e530154d74155.jpg">
    <input id="rem10" type="hidden" value="SPL FUNNEL 2">
    <input id="img10" type="hidden" value="adminpanel/product_images/4f8e53daf13e6156.jpg">
    <input id="rem20" type="hidden" value="SPL FUNNEL 3">
    <input id="img20" type="hidden" value="adminpanel/product_images/4f8e543100eaf157.jpg">
    <input id="rem30" type="hidden" value="SPL FUNNEL 4">
    <input id="img30" type="hidden" value="adminpanel/product_images/4f8e545a829e1158.jpg">
    <script>
    $(document).ready(function() {
        idrv0 = 'rem00';
        idmv0 = 'img00';
        $('#txt0').text(document.getElementById(idrv0).value);
        alert($('#txt0').text());
        $('#img0').attr('src', document.getElementById(idmv0).value);
        alert($('#img0').attr('src'));
    });

    function Change(id) {
        $('#YN').val('false');
        idrv0 = 'rem' + id;
        idmv0 = 'img' + id;
        $('#txt0').text(document.getElementById(idrv0).value);
        alert($('#txt0').text());
        $('#img0').attr('src', document.getElementById(idmv0).value);
        alert($('#img0').attr('src'));
        return true;
    }​
    </script>
    <ul>
    <li>
    <a id="00" style="text-decoration: none; text-size: 1.1em; color: " 
onclick=" Change(this.id); alert($('#txt0').text()); alert($('#img0').attr('src'));">
SPL FUNNEL 1</a>
    </li>
    <li>
    <li>
    <li>
    </ul>
    </td>
    <td valign="bottom" align="left" colspan="2">
    <td width="110px" valign="bottom" align="left" style="width: 180px">
    </tr>
  • 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-05T00:38:06+00:00Added an answer on June 5, 2026 at 12:38 am

    Gonna take a guess that each time you’re clicking an anchor, its executing a new page load. If so, you likely need to add preventDefault to the anchors onClick method.

    Assuming that your code looks something like this, add the preventDefault() where appropriate:

    $('a.availableProducts').click(function(ev){
       ev.preventDefault();
       //do image stuff or whatever
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code can be found here: http://www.myhorizon.ca/client_central/sortable_test.php Hello folks of Stackoverflow, I have a list
Code: var result = db.rows.Take(30).ToList().Select(a => AMethod(a)); db.rows.Take(30) is Linq-To-SQL I am using ToList()
Code Snippet: ShippingPeriod[] arrShippingPeriods; . . . List<ShippingPeriod> shippingPeriods = ShippingPeriodList.ToList<ShippingPeriod>(); The Last line
Code below sets default values for new row if row is added using form.
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
code: #include<iostream> using namespace std; template<class T, int N> class point { T coordinate[N];
Code: #include <iostream> using namespace std; #define ADD(x,y) ((x)+(y)) int main( int argc, char**
Code double timeout_in_hours = 6.0; MyDataContext db = new MyDataContext(); using (TransactionScope tran =
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.