18-Jul-06 (Created: 18-Jul-06) | More in 'Howto'

How to submit a form in aspire a very trivial example


<script>
function submitForm()
{
	alert("helloworld");
	var field1 = document.myform.field1.value;
	var field2 = document.myform.field2.value;
	
	var url="/your-webapp/update?request_name=CreateStudentDefinition";
	url += "&arg1=" + escape(field1);
	url += "&arg2=" + escape(field2);
	
	alert("going to update url:" + url;
	
	//Actually going there
	//You can comment this out initially until you get your final url correct
	document.location=url;
}
</script>


<form name="myform" action="submitForm()">
<input type="text" name="field1" value="samplevalue"/>
<input type="text" name="field1" value="samplevalue"/>
<input type="submit" value="CreateStudent"/>
</form>

Main features

1. The form has a proper name

2. The fields are individually named

3. The main button is the submit button

4. The action of the form is loaded with a javascript function

5. The fields are retrieved using javascript

6. The fields are then concatenated to form the update url

7. The aspire update url starts with a /webapp/update

8. The mandatory parameter to aspire update is "request_name"

9. This mandatory parameter points to a section in the aspire properties file

10. The escape function in javascript is used to escape any special characters in the user entered text

References

How to do updates in aspire, the rest of the story