Hello Dojo

An example HTML form with dojo reaction to the submit.

by Sarah Eggleston

HTML

<h3>Hello Dojo</h3>
      <div class="formSurround">
	   <label for="myText">Enter your name here</label>
	   <input id="myText" class="text" type="text">
       <button id="submitButton" class="button" >Submit Form</button>
     </div>
     <div id="response" class="respText"></div>

CSS

body {
	font-family: "Trebuchet MS", Helvetica, sans-serif;
}

h3 {
	margin-left: 130px;
}

.formSurround {
	margin-left: 20px;
	width: 320px;
	background-color: #e0e0e0;
	height: 85px;
	padding-left: 15px;
	padding-right: 15px;
}

div {
	padding-top: 10px;
}

.button {
	margin-top: 20px;
	float: right;
	font-size: 17px;
	border-radius: 4px;
}

.text {
	-moz-box-shadow: 10px 10px 5px #888;
	-webkit-box-shadow: 10px 10px 5px #888;
	box-shadow: 10px 10px 5px #888;	
}

.respText {
	color: blue;
	margin-left: 20px;
	margin-top: 10px;
}

JavaScript

require([
   "dojo/on",
   "dojo/dom", 
   
   // Needed so that on isn't called too soon
   "dojo/domReady!"
   ], 
   
   function(on, dom) {
	
     myButton = dom.byId("submitButton");
  	
	 on(myButton, "click", function(evt){
         /* Don't submit the form!! */
         evt.preventDefault();
         evt.stopPropagation();
         
         var myInput = dom.byId("myText");
         var response = dom.byId("response");
         var helloStr = "Hello ";

         response.innerHTML = helloStr + myInput.value;
     });
 
});