Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
39
rated 0 times [  45] [ 6]  / answers: 1 / hits: 15507  / 11 Years ago, tue, february 26, 2013, 12:00:00

Below is how I made an alert showing the dynamic id using onblur. I have a while loop with input fields so the id is pulling from a unique id in a database.



How would I get the value too? Normally I would just set a variable like usual but it's in a loop so I'm not understanding how.



<script type=text/javascript>
function doUpdateEntries(clicked_id) {
alert(clicked_id);
// how do I get the value AND id?
}
</script>

while ($row = mysql_fetch_assoc($result)) {
<input onblur=doUpdateEntries(this.id); id=.$row['entry_id']. name=.$row['entry_id']. type=text value=.$row['reviews'].>
}

More From » loops

 Answers
2

You could simply pass through the value to the function doUpdateEntries as another parameter.



<script type=text/javascript>
function doUpdateEntries(id, value) {
alert(id);
alert(value);
}
</script>

while ($row = mysql_fetch_assoc($result)) {
<input onblur=doUpdateEntries(this.id, this.value); id=.$row['entry_id']. name=.$row['entry_id']. type=text value=.$row['reviews'].>
}

[#80004] Sunday, February 24, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alorac

Total Points: 262
Total Questions: 82
Total Answers: 97

Location: Libya
Member since Mon, Dec 7, 2020
4 Years ago
alorac questions
Sat, Oct 10, 20, 00:00, 4 Years ago
Tue, Sep 22, 20, 00:00, 4 Years ago
Wed, Jul 1, 20, 00:00, 4 Years ago
Wed, Jun 3, 20, 00:00, 4 Years ago
Sun, May 17, 20, 00:00, 4 Years ago
;