| | 1 | <html> |
| | 2 | <head> |
| | 3 | <title>Test of dojo.io.FormBind</title> |
| | 4 | </head> |
| | 5 | <body> |
| | 6 | NB: This page uses some "document.write" statements to print JS variables, please allow the blocked content for it to operate properly! |
| | 7 | |
| | 8 | <br> |
| | 9 | <br> |
| | 10 | |
| | 11 | <b> |
| | 12 | The two forms below both use dojo.io.FormBind to submit through Dojo. |
| | 13 | <br> |
| | 14 | The response handler simply uses alert() to signal that the rsponse was received. |
| | 15 | <br> |
| | 16 | The purpose of this test is to verify that form submission behavior is consistent between IE and Firefox. |
| | 17 | Notably, that the problem reported in tracker #2844 is fixed. |
| | 18 | </b> |
| | 19 | |
| | 20 | <br> |
| | 21 | <br> |
| | 22 | |
| | 23 | Here is a good form: |
| | 24 | <form name="testform_good" id="testform_good_id" action="test_FormBind.html" method="POST"> |
| | 25 | <input type="submit" name="input1" value="input1"/> |
| | 26 | <br> |
| | 27 | <input type="submit" name="not_action" value="not_action"/> |
| | 28 | </form> |
| | 29 | |
| | 30 | Here is a bad (from IE's handling of attributes such as action and method) form: |
| | 31 | <form name="testform_bad" id="testform_ie_bad_id" action="test_FormBind.html" method="POST"> |
| | 32 | <input type="submit" name="input1" value="input1"/> |
| | 33 | <br> |
| | 34 | <input type="submit" name="action" value="action"/> |
| | 35 | </form> |
| | 36 | |
| | 37 | <br> |
| | 38 | <br> |
| | 39 | |
| | 40 | <b> |
| | 41 | Below you can see the various ways to try to get the form's action and their results for each form. |
| | 42 | <br> |
| | 43 | Load this page on FF and on IE and verify the form submission works properly. |
| | 44 | </b> |
| | 45 | |
| | 46 | <script src="../../dojo.js" type="text/javascript"></script> |
| | 47 | <script type="text/javascript"> |
| | 48 | dojo.require("dojo.io.BrowserIO"); |
| | 49 | var tfgood = document.getElementById( "testform_good_id" ); |
| | 50 | var tfiebad = document.getElementById( "testform_ie_bad_id" ); |
| | 51 | |
| | 52 | var handler = function(){ |
| | 53 | alert( "response received" ); |
| | 54 | }; |
| | 55 | |
| | 56 | // Bind the form submission (by button click) to the callback method |
| | 57 | var reqHeaders = new Array(); |
| | 58 | reqHeaders["If-Modified-Since"] = "Sat, 1 Jan 2000 00:00:00 GMT"; |
| | 59 | var x = new dojo.io.FormBind( |
| | 60 | { |
| | 61 | headers: reqHeaders, |
| | 62 | mimetype: "text/html", |
| | 63 | formNode: tfgood, |
| | 64 | load: handler |
| | 65 | } |
| | 66 | ); |
| | 67 | var y = new dojo.io.FormBind( |
| | 68 | { |
| | 69 | headers: reqHeaders, |
| | 70 | mimetype: "text/html", |
| | 71 | formNode: tfiebad, |
| | 72 | load: handler |
| | 73 | } |
| | 74 | ); |
| | 75 | |
| | 76 | |
| | 77 | document.write( "<br><br><b>form.action</b><br>" ); |
| | 78 | document.write( "This will return an input element named 'action' on both browsers." ); |
| | 79 | document.write( "<br>" ); |
| | 80 | document.write( "testform_good.action: " + tfgood.action ); |
| | 81 | document.write( "<br>" ); |
| | 82 | document.write( "testform_bad.action: " + tfiebad.action ); |
| | 83 | |
| | 84 | document.write( "<br><br><b>form.getAttribute( 'action' )</b><br>" ); |
| | 85 | document.write( "This will return an input element named 'action' on IE, but the form action on FF." ); |
| | 86 | document.write( "<br>" ); |
| | 87 | document.write( "testform_good.getAttribute( 'action' ): " + tfgood.getAttribute( "action" ) ); |
| | 88 | document.write( "<br>" ); |
| | 89 | document.write( "testform_bad.getAttribute( 'action' ): " + tfiebad.getAttribute( "action" ) ); |
| | 90 | |
| | 91 | document.write( "<br><br><b>form.getAttributeNode( 'action' ).value</b><br>" ); |
| | 92 | document.write( "This will return the form action on both browsers." ); |
| | 93 | document.write( "<br>" ); |
| | 94 | document.write( "testform_good.getAttributeNode( 'action' ).value: " + tfgood.getAttributeNode( "action" ).value ); |
| | 95 | document.write( "<br>" ); |
| | 96 | document.write( "testform_bad.getAttributeNode( 'action' ).value: " + tfiebad.getAttributeNode( "action" ).value ); |
| | 97 | </script> |
| | 98 | </body> |
| | 99 | </html> |