-1

I have multiple items on a php page, to edit each item, i want to send the title of the button as a parameter to an iFrame (popup), how can i do this ?

i have a code like this :

<button class="btn_edit ui-button-text-only" title="245" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="246" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="247" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="248" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

<button class="btn_edit ui-button-text-only" title="249" role="button" aria-disabled="false"><span class="ui-button-text">Edit this item</span></button>

itemID = the title variable.

to get similar result : iframe src="index.php?type=1296727025&itemID.

I tried to append() but didn't work,

$dialog_edit.append($("<iframe class='no-border full-width-height' />").attr("src", "index.php?type=1296727025&tx_productmanager_pi1="+productID+"&no_cache=1"));
$dialog_edit.dialog('open');

Does any one has an idea ?

Mohamed Masmoudi
  • 547
  • 1
  • 9
  • 23
  • what's your other code for `append()`? – Sagar Guhe Feb 16 '16 at 10:12
  • Mi append code is this : $('.btn_edit_product').click(function() { var productID = $(this).attr('title'); $dialog_edit.append($("").attr("src", "index.php?type=1296727025&tx_productmanager_pi1[productID]="+productID+"&no_cache=1")); alert (productID); // This alert show me the productID $dialog_edit.dialog('open'); return false; }); – Mohamed Masmoudi Feb 16 '16 at 12:46

2 Answers2

1

        
         
    
           $(document).ready(function(){
    
           $('.my-button').click(function() {
    
            var title = $(this).attr("title");
            var src =  "index.php?type=1296727025&itemID=" + title;
             console.log(src);
            $("#my-div").html("<iframe src='" + src + "' width='100%' height='600'></iframe>");
    
          });
    
        });
    
        
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="btn_edit ui-button-text-only my-button" title="245" role="button" aria-disabled="false">
  <span class="ui-button-text">Edit this item</span>
</button>
<button class="btn_edit ui-button-text-only my-button" title="242" role="button" aria-disabled="false">
  <span class="ui-button-text">Edit this item</span>
</button>
 <div id="my-div">
 </div>

  
 
HelpMan
  • 11
  • 3
0

I have created a demo on my local and it is working fine. Do check below code. As abc.php is not real path or file, it will not show actual result here.

$(document).ready(function() {
  $('#button').click(function() {
    $("#myIframe").html('<iframe id="myIframe" src="abc.php?id=12" width=500 height=500></iframe>');
    var Isrc = $("#myIframe").attr('src');
    Isrc = Isrc;
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<button id="button">Click Me</button>
  <div id="myIframe">
  </div>
PHPExpert
  • 945
  • 5
  • 9