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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:27:58+00:00 2026-05-31T07:27:58+00:00

This is code for generating page: <div id=mali_oglasi> <?php foreach ($mgs as $key) :

  • 0

This is code for generating page:

<div id="mali_oglasi">
    <?php foreach ($mgs as $key) : ?>
    <p class="mali_oglas">
        <span class="name"><?php echo $key['name'] ?></span>
        <span class="body"><?php echo $key['body'] ?></span>
        <span class="contact_author"><?php echo $key['contact_author'] ?></span>
        <span class="date_created"><?php echo $key['date_created'] ?></span>
        <span class="date_expires"><?php echo $key['date_expires'] ?></span>
        <span class="email"><?php echo $key['email'] ?></span>
    <?php foreach ($lokacija as $lok) : ?>
    <?php if($lok['id_location'] == $key['location_id']) : ?>
        <span class="lokacija" id="<?php echo $lok['id_location'] ?>"><?php echo $lok['name'] ?></span>
    <?php endif ?>
    <?php endforeach; ?>

    <?php foreach ($kategorija as $kat) : ?>
    <?php if($kat['id_category'] == $key['category_id']) : ?>
        <span class="kategorija" id="<?php echo $kat['id_category'] ?>"><?php echo $kat['name'] ?></span>
    <?php endif ?>
    <?php endforeach; ?>
    <a class="obrisi" id="<?php echo $key['id_global_info'] ?>">Obrisi</a>
    <a class="izmeni" id="<?php echo $key['id_global_info'] ?>">Izmeni</a>
</p>
    <?php endforeach; ?>
</div>

which will give this result:

<div id="mali_oglasi">
        <p class="mali_oglas">

        <span class="name">fbsd</span>
        <span class="body">sdhdsf</span>
        <span class="contact_author">mirko</span>
        <span class="date_created">2012-03-15 11:24:19</span>
        <span class="date_expires">2012-04-14 11:24:19</span>
        <span class="email">a@a.com</span>

                <span class="lokacija" id="1">Pirot</span>

                <span class="kategorija" id="1">Auto i Moto</span>
                                                                                                                                                                                                            <a class="obrisi" id="19">Obrisi</a>
    <a class="izmeni" id="19">Izmeni</a>
</p>
        <p class="mali_oglas">
        <span class="name">dsh</span>

        <span class="body">dshg</span>
        <span class="contact_author">mirko</span>
        <span class="date_created">2012-03-15 11:17:52</span>
        <span class="date_expires">2012-04-14 11:17:52</span>
        <span class="email">a@a.com</span>
                <span class="lokacija" id="1">Pirot</span>


                <span class="kategorija" id="1">Auto i Moto</span>
                                                                                                                                                                                                            <a class="obrisi" id="18">Obrisi</a>
    <a class="izmeni" id="18">Izmeni</a>
</p>....
</div>

and JS for replaceWith and load:

$(parent).on('click', '.izmeni', function() {
    var name = $(this).siblings('.name').text();
    var body = $(this).siblings('.body').text();
    var email = $(this).siblings('.email').text();
    var contact_author = $(this).siblings('.contact_author').text();
    var id_lok = $(this).siblings('.lokacija').attr("id");
    var id_kat = $(this).siblings('.kategorija').attr("id");

    $(this).siblings('.name').replaceWith('<input value="' + name + '" />');
    $(this).siblings('.body').replaceWith('<textarea>' + body + '</textarea>');
    $(this).siblings('.date_created').hide();
    $(this).siblings('.date_expires').hide();
    $(this).siblings('.email').replaceWith('<input value="' + contact_author + '" />');
    $(this).siblings('.lokacija').replaceWith(function(){
        $(this).load("<?php echo base_url() ?>form/location", {'id' : id_lok})
    });
    $(this).siblings('.kategorija').replaceWith(function(){
        $(this).load("<?php echo base_url() ?>form/category", {'id' : id_kat})
    });

});

load is calling following page (for lokacija):

<select>
<?php foreach ($lokacija as $lok) : ?>
    <option 
    <?php if($lok['id_location'] == $id) : ?>
        selected="selected"
    <?php endif ?>>
        <?php echo $lok['name'] ?>
    </option>
    <?php endforeach; ?>
</select>

Everything except lokacija and kategorija is replaced, but in the firebug I am getting positive response (page requested page is loaded without the errors but it is not displayed). What am I doing wrong?

  • 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-31T07:27:59+00:00Added an answer on May 31, 2026 at 7:27 am

    Dosent LOAD and REPLACEWITH both replace the content, so you are replacing the replaced the content.

    So can’t you just either add the ID to the load method, or make a normal ajax GET and the use the replacewith function?

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

Sidebar

Related Questions

I have the following code generating content on my site: <div class=content id=links> <?php
The following code is generating a page not found error with Kohana 2.3.4 class
This code works great for generating thumbnails, but when given a very large (100MB+)
this code always returns 0 in PHP 5.2.5 for microseconds: <?php $dt = new
How do I code a Facebook quote application taking its data from PHP/MySQL page
This code should not generate any HTML button dynamically. Coz there is no div
I have a website which is code generating practically everything on the page. The
This code / markup... <ul id="tag-directory" class="clearfix"> <li py:for="tag in tags"><a href="${h.url_for(controller='/media', action='index', tag=tag.slug)}">${tag.name}</a>
So I am generating a table with php/mysql, and in this table are numbers
i am dynamically generating a html page using php in which i am generating

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.