intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Processing Validated Data

Chia sẻ: Qweqwdasd Qweqdasda | Ngày: | Loại File: PDF | Số trang:3

65
lượt xem
5
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Chế biến xác nhận dữ liệu Nhiệm vụ cuối cùng cho các ứng dụng của chúng tôi là để gửi tất cả dữ liệu xác nhận đến một máy chủ để xử lý. Chúng tôi sẽ sử dụng một đối tượng LoadVars để hoàn thành mục tiêu này. 1. Mở validate6.fla. Chúng tôi sẽ tiếp tục xây dựng trên dự án từ các tập thể dục trước đó.

Chủ đề:
Lưu

Nội dung Text: Processing Validated Data

  1. < Day Day Up > Processing Validated Data The last task for our application is to send all the validated data to a server for processing. We'll use a LoadVars object to accomplish this goal. 1. Open validate6.fla. We'll continue building on the project from the preceding exercise. 2. With the Actions panel open, select Frame 1 of the Actions layer and add the following script at the top of the current script, just below the stop() action: 3. 4. var registrationData:LoadVars = new LoadVars(); 5. This creates a new LoadVars object named registrationData. In the next step we will add a script that places our validated data into this object and sends it to the server. 3. Add the following script to the else leg of the validateForm() function: 4. 5. 6. registrationData.name = name_ti.text; 7. 8. registrationData.email = email_ti.text; 9. 10. registrationData.state = state_ti.text; 11. 12. registrationData.zip = zip_ti.text; 13. 14. registrationData.sendAndLoad("http://www.myDomain.com/registration.php", registrationData, 15. 16. "POST"); 17. When all the data entered into the form is valid, the actions in the else part of the validateForm() function—including this section of script—are executed.
  2. The first four lines of the script place the data in the various TextInput instances into the registrationData object. The last line sends this data to a server-side script. NOTE For the last line of script, you should insert the URL to a script on your server for processing the data. Or, if you simply want to do a final test of your code, use this URL: http://www.derekfranklin.com/cftemplates/notsosoft.cfm. The ColdFusion page at this URL will send you email containing the validated data. The else part of this script already had an action that would send the application to the Confirm label automatically when all the data entered was valid. Because the application is now set up to send data to a server, let's change this functionality a bit so that the application only moves to that frame label after a response has been received from the server, indicating that the submitted data has been received and processed. 4. Remove the line of script in the else leg of the validateForm() function that reads gotoAndStop("Confirm") and insert the following script just above the sendAndLoad() method call: 5. 6. registrationData.onLoad = function(){ 7. 8. gotoAndStop("Confirm"); 9. 10. } 11.
  3. This script will move the application to the Confirm label when a server response has been sent back to the registrationData object. Let's do one final test. NOTE Before testing, make sure that the URL specified in the sendAndLoad() method discussed in Step 3 contains a server-side script for handling the incoming data. 5. Choose Control > Test Movie. If you enter valid data into the form fields and click the Submit button, the application should send the data to the specified server-side script for processing, and eventually move the application's timeline to the Confirm label after a response has been received from the server. 6. Close the test movie to return to the authoring environment, and save this file as validate7.fla. This step completes the exercise and this lesson. The great thing about the way we've set up this project's validation process is that it's dynamic. To analyze additional rules or validation points for any of the text fields, all you have to do is add more conditional statements to the appropriate function. The validation process can grow as your needs grow. < Day Day Up >
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2