last day (14 days later) » 

12:20 PM
0
A: Can't get all id in php which loop using jquery

JenzAs you are replacing value of $kid to echo "<input type='hidden' id='kid' value='$kid'/>"; each time, it will contain only the last looped row's value. Instead of calling the Jquery function on clicking the div, call that function on clicking each tr's. while($result = mysql_fetch_array(...

 
Then what it's should be ?
 
You need all keywords together right?
 
Yes, In while loop I need all Keywords id (kid). Then I can get different kid when I click on each Keyword name.
 
@Shibbir..Please see my updated answer and let me know for any doubts.
 
Ok. I'm checking it.
It's showing me SyntaxError: syntax error keywordclick(55,);
In console log.
 
12:20 PM
sorry it is $cdid instead of $cid, in hidden field..My mistake
 
Ok. It's working now. Can you tell why it's not working in my Code ?
 
hi
 
Hello
 
in your code, you are defining hidden fields each time with each loops value
and you are calling the jquery function on a common div
so that it wont get each values
for getting values corresponding to each rows
you have to call the jquery function within the loop itself
echo "<input type='hidden' id='kid' value='$kid'/>";
each time this will be replaced with current row's value
so when u click the div
$('#keywordBox').click(function(e) {
` var kid = $('#kid').val();
var cdid = $('#cdid').val(); `
these will have the current rows values
Is it clear for you now?
 
But in browser history page I see different kid
may be if i used class then it could be ok and need to change the jquery code.
 
12:29 PM
if you are creating the hidden field within the loop, then it should have different ids
otherwise it will get replaced
 
got it. Thanks.
 

last day (14 days later) »