getElementById("commentForm").style;
if (elm.display == "none")
{
elm.display = "block";
}
else
{
elm.display = "none";
}
}
Mobile AJAX
[ 196 ]
3. When the user clicks the link, she or he will see the form. On clicking the
button in the form, we are calling a JavaScript function SubmitComment().
What we need to do in this function is get the recipeId from the hidden
form that the AJAX call has sent, collect other variables from the comment
form, and send them to the recipeHandler.
function SubmitComment(frm)
{
// Copy the recipeId value from the hidden form
// received from AJAX
// to the comment form
var src = document.recipeHiddenInfo;
var target = document.formComment;
var url = "?action=recipeHandler&what=comment";
url += "&recipeId=" + src.recipeId.value;
url += "&submitter=" + target.submitter.value;
url += "&submitterPhone=" + target.submitterPhone.value;
url += "&comment=" + target.comment.value;
ShowDetails(url, 'commentForm', false, false);
}
4. Now we can write the back end code to save the comment to the table. It's
straightforward now that we have created the RecipeComment class. We need
to add code to the recipeHandler to save the comment when the value of
the what variable is comment! We can populate the class with the data coming
in the request, set the date, and save it.
Pages:
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263