I have to write in a textarea but i have two “id” equal because i create the form for changing data.
If the form is:
<form method="GET" name="formparam" id="formparam" action="${nextstep}">
<label>ID</label></td><td>
<textarea class="expand" name="inputp'+v+'_id" id="inputp'+v+'_id">
</textarea>
</form>
And for Call i use this script:
function qs(key) {
key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx control chars
var match = location.search.match(new RegExp("[?&]" + key + "=([^&]+)(&|$)"));
return match && decodeURIComponent(match[1].replace(/\+/g, " "));
}
function Pcompila(v){
var i;
var Listparam=['_id','_description','_info','_type','_value'];
for (i=0;i<Listparam.length;i++)
{
var a ='inputp'+v+ Listparam[i];
alert(a);
if (location.search) {
var p=qs(a);
alert(p);
$('#'+a).text(p);
}
}
return;
}
Where $('#'+a).text(p); is wrong because don’t write.
How to change for calling the id in a form???.
I try with this:
$("formparam").$('#'+a).text(p);
This is a absolute wrong!!!
$("formparam")is not correct becauseformparamis not an element type, it should be#formparamto search for an ID. And the way to search for one element inside another is to use.find(), e.g.$("#formparam").find("#"+a). But since IDs must be unique, you don’t really need to say where to search for them, so you can just use$("#"+a), as in Pulkit Mittal’s answer.