Skip to content

Instantly share code, notes, and snippets.

@cfalzone
Created November 7, 2013 18:08
Show Gist options
  • Save cfalzone/7359189 to your computer and use it in GitHub Desktop.
Save cfalzone/7359189 to your computer and use it in GitHub Desktop.
Combine 2 fields for custom urlTitle field
#set($cusFieldVarName="urlTitle")
#set($f1VarName = "coursePrefix")
#set($f2VarName = "courseNumber")
<script>
function updateDisplayURLTitle() {
// get the fields entered by the user
var f1 = dojo.byId("${f1VarName}");
var f2 = dojo.byId("${f2VarName}");
// combine the fields
var urlTitle = f1.value+"-"+f2.value;
dojo.byId("display${cusFieldVarName}").innerHTML = urlTitle;
dojo.byId("${cusFieldVarName}").value=urlTitle;
}
// attach this the text1 field onchange
dojo.addOnLoad(function(){
dojo.connect(dojo.byId("${f1VarName}"), "onchange", null, "updateDisplayURLTitle");
dojo.connect(dojo.byId("${f2VarName}"), "onchange", null, "updateDisplayURLTitle");
}
);
// populate the field on load
dojo.addOnLoad(updateDisplayURLTitle);
</script>
<div id="display${cusFieldVarName}" style="height:20px"> </div>​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment