0
<?php
$count= 5;
$abc= $count+1; 
$new_id="<span id='att'>".$abc."</span>";
?> 

<script>
$('#new_product').find('.product_id').select2();
var attnum = 5;
$('#btn_add_prod').click(function(e) { 

    document.getElementById('att').innerHTML = ++attnum;
    $('element').attr('id', 'value');  
});
</script> 

<html><input type="text" id="id_<?php echo $new_id?>"/></html>

I would like to get id as "id_6", "id_7","id_8". But here it print like "id_".$abc."" I would appreciate your help. Thanks.

SUC
  • 1
  • 1
  • 1
    Please [edit] your question to show [the code you have so far](http://whathaveyoutried.com). You should include at least an outline (but preferably a [mcve]) of the code that you are having problems with, then we can try to help with the specific problem. You should also read [ask]. – Toby Speight Jun 20 '17 at 11:03
  • Your code doesn't match your question and it isn't clear what you're trying to do. Is AJAX (a JavaScript technology) actually relevant? – Álvaro González Jun 20 '17 at 11:05
  • @ÁlvaroGonzález please check the code snippet now. Thanks. – SUC Jun 20 '17 at 11:26
  • There's still no AJAX in your question and now we also have JavaScript tags. If this a JavaScript question, the PHP part is irrelevant. If this a PHP question, I'm not sure of what role JavaScript plays. I'm sorry but I can't grasp any meaning from your code, not even figure out your intentions. Maybe others are more capable. – Álvaro González Jun 20 '17 at 11:33

0 Answers0