MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual page 704

Developing coldfusion mx applications
Table of Contents

Advertisement

Click Serialize to serialize the resulting data.
6
The resulting WDDX packet appears in the WDDX packet display box. This step is intended
only for test purposes. Real applications handle the serialization automatically.
Click Submit to submit the data.
7
The WDDX packet is transferred to the server-side processing code, which deserializes it and
displays the information.
<!--- load the wddx.js file --->
<script type="text/javascript" src="/CFIDE/scripts/wddx.js"></script>
<!--- Data binding code --->
<script>
// Generic serialization to a form field
function serializeData(data, formField) {
wddxSerializer = new WddxSerializer();
wddxPacket = wddxSerializer.serialize(data);
if (wddxPacket != null) {
formField.value = wddxPacket;
}
else {
alert("Couldn't serialize data");
}
}
// Person info recordset with columns firstName and lastName
// Make sure the case of field names is preserved
var personInfo = new WddxRecordset(new Array("firstName", "lastName"),
true);
// Add next record to end of personInfo recordset
function doNext() {
// Extract data
var firstName = document.personForm.firstName.value;
var lastName = document.personForm.lastName.value;
// Add names to recordset
nRows = personInfo.getRowCount();
personInfo.firstName[nRows] = firstName;
personInfo.lastName[nRows] = lastName;
// Clear input fields
document.personForm.firstName.value = "";
document.personForm.lastName.value = "";
// Show added names on list
// This gets a little tricky because of browser differences
var newName = firstName + " " + lastName;
if (navigator.appVersion.indexOf("MSIE") == -1) {
document.personForm.names[length] =
new Option(newName, "", false, false);
}
else {
// IE version
var entry = document.createElement("OPTION");
entry.text = newName;
document.personForm.names.add(entry);
}
}
</script>
704
Chapter 31: Using XML and WDDX

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents