DeletedUser
Guest
So, I'm trying to build a livesearch-esque function into my site (similar to grepointel, when you search for a town ID and it comes back with the town name and the player's name). I've got the search to work, I have returned the results, that all works. I'm now trying to have it so when the user clicks on the TR element, it populates the fields with the data the PHP script returned.
I checked the page, and its getting all of the values properly, and its calling the function like this:
Here's the Javascript (my javascript is pretty bad, lol):
And here is the form:
When clicking on the TR, I get this in the console (for Google Chrome):
I set them to readonly because I want them to either populate the form with AJAX, or submit without it, and let PHP handle it. I tried removing the readonly attribute, but the exact same error occurred, so I left it in.
Any ideas?
I checked the page, and its getting all of the values properly, and its calling the function like this:
HTML:
<tr class="town_result" onclick="popForm('1234', 'SomePlayer', 'Some MRA', 'Someplayers Town', '175')">
Here's the Javascript (my javascript is pretty bad, lol):
Code:
function popForm(town_id, player_name, alliance_name, town_name, town_points) {
document.getElementById('town_id').value=town_id;
document.getElementById('player_name').value=player_name;
document.getElementById('alliance_name').value=alliance_name;
document.getElementById('town_name').value=town_name;
document.getElementById('town_points').value=town_points;
}
And here is the form:
HTML:
<form method="post" action="add_claim.php">
<table class="add_claim">
<tr class="even_row" id="add_claim_headers">
<td><label for="town_id">Town ID</label></td>
<td><label for="player_name">Player Name</label></td>
<td><label for="alliance_name">Alliance Name</label></td>
<td><label for="town_name">Town Name</label></td>
<td><label for="town_points">Town Points<label></td>
<td></td>
<tr class="odd_row">
<td><input type="text" id="town_id" name="town_id" autocomplete="off" onkeyup="queryDB(this.value)" /><div id="targetDiv"></div></td>
<td><input type="text" id="player_name" name="player_name" readonly="readonly" /></td>
<td><input type="text" id="alliance_name" name="alliance_name" readonly="readonly" /></td>
<td><input type="text" id="town_name" name="town_name" readonly="readonly" /></td>
<td><input type="text" id="town_points" name="town_points" readonly="readonly" /></td>
<td><input type="submit" id="add_claim" value="Add Claim" /></td>
</tr>
</table>
</form>
When clicking on the TR, I get this in the console (for Google Chrome):
Code:
Uncaught SyntaxError: Unexpected token ILLEGAL index.php:1
I set them to readonly because I want them to either populate the form with AJAX, or submit without it, and let PHP handle it. I tried removing the readonly attribute, but the exact same error occurred, so I left it in.
Any ideas?