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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:32:30+00:00 2026-06-16T21:32:30+00:00

I have a table generated by php and implementing a modal to allow user

  • 0

I have a table generated by php and implementing a modal to allow user to change the text generated by variable $l_id; I have a link class “eloc” that show’s the modal div section. I intercept the form submit id “renameLocation” and process the input and disable the default submit action. I want to modify show the new text renamed by the user.

I have this php code which repeated by iterating an array, the iteration id is $l

$id_l="\"location_".$l."\"";
echo "<table class=\"add\" border=\"1px\" width=\"100%\">";
echo "<tr class=\"header\"><td class=\"stretch\"><a class=\"eloc\" rel=\"leanModal\" href=\"#modal_location\"><img src=\"images/edit-icon.png\" alt=\"Location\"></a></td><td id=\"".$id_l."\" class=\"location\" colspan=\"6\">Location: ".$row['location']."</td></tr>";

Then I have a div:

<div id="modal_location" class="modal_prompt">      
    <div class="modal_prompt-ct">           
        <div class="modal_prompt-header">
            <h2>Rename Location</h2>
            <a class="modal_close" href="#"></a>            
        </div>

        <form id="renameLocation">
            <div class="txt-dpy">
                <span id="mlocation_name"></span>
            </div>
            <div class="txt-fld">
                <label for="">Change to</label> 
                <input id="newLocation" name="" type="text" />
            </div>
            <div class="btn-fld">
                <button type="submit">Save &raquo;</button>
            </div>          
        </form>         
    </div>  
</div>

How to modify the text for the generated $l_id?

$("#renameLocation").submit(function(e) 
{
    $("#lean_overlay").fadeOut(200);
    $("#modal_location").css({"display" : "none" })
    // How to modify the text of "$l_id"?
    return false; //do not submit form the normal way        
});

Many thanks.

  • 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-16T21:32:31+00:00Added an answer on June 16, 2026 at 9:32 pm

    Question is ambiguous. It sounds like you have more than one text to edit.

    You need a way to tell JS which location to update so add a global variable. It’s not usual way you’d do this but it should be okay.

    Add data to the element

    $id_l="\"location_".$l."\"";
    echo "<table class=\"add\" border=\"1px\" width=\"100%\">";
    echo "<tr class=\"header\"><td class=\"stretch\"><a class=\"eloc\" rel=\"leanModal\" href=\"#modal_location\" 
        data-location=\"".$l."\"><img src=\"images/edit-icon.png\" alt=\"Location\"></a></td><td id=\"".$id_l."\" class=\"location\" colspan=\"6\">Location: ".$row['location']."</td></tr>";
    

    set this at the top of your js

    var selectedlocation=0;
    

    bind clicking the edit link to set selectedlocation

    $('.eloc').on('click', function(){
        selectedlocation=$(this).data('location');
    });
    

    use the var in your code

    $("#renameLocation").submit(function(e) 
    {
        var location=$(this).data('location');
        $("#lean_overlay").fadeOut(200);
        $("#modal_location").css({"display" : "none" })
        $('#location_'+selectedlocation).text();
        e.preventDefault(); //return false; //do not submit form the normal way        
    });
    

    Here’s another way

    Forget the global variable.

    Add a hidden form field

    <form id="renameLocation">
        <input type="hidden" name="location" value="" id="renameLocation_location"/>
    

    Put the value in that

    $('.eloc').on('click', function(){
        $('#renameLocation_location').val($(this).data('location'));
    });
    

    And use that.

    $('#location_'+ $('#renameLocation_location').val() ).text();
    

    The way you have provided it, the modal is totally independant to the links you need something to set somewhere to achieve what you want.

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

Sidebar

Related Questions

I have a table generated by PHP/mysql, I want a user to click the
I have a table being generated from PostgreSQL through PHP. The user needs to
I have two checkboxes generated like this: <table> <?php foreach ($invited_members as $mem) :
Fiddle: http://jsfiddle.net/MhWm5/16/ I have some dynamically generated table rows/values with dynamic IDs <td class=control-group>
I have a table generated from some PHP code that lists a SMALL amount
I have a table which is generated by a php function in which, each
I have a table list of products generated in PHP. The list contains: title
I have a table that has been generated dynamically using PHP. The table has
I have a dynamically generated table with php that has same rows. Need to
I have a table whose values are being generated dynamically with PHP, including the

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.