View Full Version : AJAX Values Sent to Modify Form but then Undefined on Update

09-14-2007, 11:07 PM
I have a common area called "leftbox" which I dump HTML code to. The Add works fine, however the Modify has a problem the response from my PHP call gets the correct record information and the form appears to be set up correctly. When I click on the Modify button, the call executes the PHP, however the values from the form are passed as undefined.

var modify_firstname = "";
var modify_lastname = "";

// at this point the get_key, get_firstname, get_lastname values are confirmed to exist.
document.getElementById('leftbox').innerHTML="<b>LEFTBOX(GET):<br></b>" +
"<form id=\"harvester_form\">" +
"Enter Harvestor Information and Click Modify" +
"<br>First Name: <input type=\"text\" id=\"modify_firstname\" size=\"30\" value=\"" + get_firstname + "\"/><br>" +
"<br>Last Name: <input type=\"text\" id=\"modify_lastname\" size=\"30\" value=\"" + get_lastname + "\"/><br>" +
"<input type=\"button\" onclick=\"ajaxFunction('harvester_key=" + get_key + "&harvester_firstname=" + modify_firstname.value + "&harvester_lastname=" + modify_lastname.value + "','harvest_modify_harvester.php');\" value=\"Modify\"/>" +

09-15-2007, 12:55 AM
Your inputs don't have names, has to have a name to get passed to the server. ID is not the same. Also if you enclose your string with single quotes you could save yourself a lot of escaping. You should also close your br tags (<br /> ) I wouldn't mention it, but you are doing right by your inputs so may as well keep it consitent.