Created
November 7, 2013 18:08
-
-
Save cfalzone/7359189 to your computer and use it in GitHub Desktop.
Combine 2 fields for custom urlTitle field
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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