<html> <head> <title>RS Example</title> </head> <body> <SCRIPT language="JavaScript" src="cgi-bin/rs.htm"></SCRIPT> <SCRIPT LANGUAGE="javascript"> RSEnableRemoteScripting("cgi-bin"); // This gets the data from the server function GetData (idnum) { var objServer = RSGetASPObject("rsexampleback.asp"); objServer.GetData(idnum, PopulateForm, WriteError); } function DecomposeData(objData) { // If an array was returned if (typeof(objData.return_value[0]) == "object") { var arrData = new Array(); var row = 0; var numcols = objData.return_value[0].length; // Place each row into the first dimension of the array. while (row < objData.return_value.length) { arrData[row] = new Array(); // Put each field into the second dimension of the array. for (var columns = 0; columns < numcols; columns++) { arrData[row][columns] = objData.return_value[row][columns]; } row++; } return arrData; } // If the SQL statement was not a SELECT statment, a single string value is returned. else { return objData.return_value; } } function PopulateForm(objData) { var arrData = DecomposeData(objData); intEmployeeID = arrData[0][0]; strFirstName = arrData[0][1]; strLastName = arrData[0][2]; strAddress = arrData[0][3]; strCity = arrData[0][4]; strState = arrData[0][5]; intZip = arrData[0][6]; strNotes = arrData[0][7]; document.employeedata.employeeid.value = intEmployeeID; document.employeedata.firstname.value = strFirstName; document.employeedata.lastname.value = strLastName; document.employeedata.address.value = strAddress; document.employeedata.city.value = strCity; document.employeedata.state.value = strState; document.employeedata.zip.value = intZip; document.employeedata.notes.value = strNotes; } function UpdateInfo(){ intEmployeeID = document.employeedata.employeeid.value; if (intEmployeeID != "") { strFirstName = document.employeedata.firstname.value; strLastName = document.employeedata.lastname.value; strAddress = document.employeedata.address.value; strCity = document.employeedata.city.value; strState = document.employeedata.state.value; intZip = document.employeedata.zip.value; strNotes = document.employeedata.notes.value; var strContextMessage = "The informaton for " + strFirstName + " " + strLastName + " has been updated."; var objServer = RSGetASPObject("rsexampleback.asp"); objServer.UpdateInfo(intEmployeeID, strFirstName, strLastName, strAddress, strCity, strState, intZip, strNotes, ClearForm, WriteError, strContextMessage); } } function ClearForm(objReturn){ for (var formelement = 0; formelement < document.employeedata.length; formelement++) { document.employeedata.elements[formelement].value = ""; } alert(objReturn.context); } function WriteError(objReturn) { var errorwindow = window.open("","error_window","width=800,height=500,status=0,toolbar=0,location=0,menubar=0") errorwindow.document.write("<b>Data:</b><br>" + objReturn.data + "<br><b>ID:</b>" + objReturn.id + "<br><b>Message:</b> " + objReturn.message + "<br><b>Status:</b> " + objReturn.status + "<br><b>Return Value:</b> " + objReturn.return_value); } </script> <form name="employeedata"> <h3>Employee Information</h3> <table border="0" cellpadding="1" cellspacing="0"> <tr> <td colspan="3">Name</td> </tr> <tr> <td><input type="text" name="firstname"></td> <td colspan="2"><input type="text" name="lastname"></td> </tr> <tr> <td colspan="3">Address</td> </tr> <tr> <td colspan="3"><input type="text" name="address" size="45"></td> </tr> <tr> <td>City</td> <td>State</td> <td>Zip</td> </tr> <tr> <td><input type="text" name="city"></td> <td><input type="text" name="state" size="3"></td> <td><input type="text" name="zip" size="8"></td> </tr> <tr> <td colspan="3">Notes</td> </tr> <tr> <td colspan="3"><textarea cols="37" rows="5" name="notes" wrap="soft"></textarea></td> </tr> </table> <input type="hidden" name="employeeid"> </form> <a href="javascript:UpdateInfo();">Update Information</a><br> <h3>Choose an Employee</h3> <a href="javascript:GetData(1);">Nancy Davolio</a><br> <a href="javascript:GetData(2);">Andrew Fuller</a><br> <a href="javascript:GetData(3);">Janet Leverling</a><br> <a href="javascript:GetData(4);">Margaret Peacock</a><br> <a href="javascript:GetData(5);">Steven Buchanan</a><br> <a href="javascript:GetData(6);">Michael Suyama</a><br> <a href="javascript:GetData(7);">Robert King</a><br> <a href="javascript:GetData(8);">Laura Callahan</a><br> <a href="javascript:GetData(9);">Anne Dodsworth</a><br> <br> </body> </html>