brentnicholas
07-19-2007, 08:03 PM
Hey all -
So I'm totlly stuck on this and can't figure it out.
I've got a button on a form and it's supposed to call two functions.
1) A form validation
2) A function to call dojo to load the next page and do some other stuff.
<input type="button" value="Save" onclick="GROUPS_validate_data_onsubmit(); return true; updateGroup(37);">
Now I'm pretty sure the 'return true' is out of place..?? It works if I take the second function (updateGroup) out all together...
What's happening now (if I leave 'return true' out), is that the validation function will fire, but then when I correct the error, none of the funtions seem to fire.. or at least the updateGroups doesn't..
So any ideas on what I'm doing wrong?
Code below:
----------------------------------------------
<form name="GROUP_EDIT_FORM" method="post">
<input type="Text" name="GROUP_NAME" value="">
<SELECT name="TEAM_ID">
<OPTION value="">
<OPTION value="1">Team
</select>
<input type="button" value="Save" onclick="GROUPS_validate_data_onsubmit(); return true; updateGroup(37);">
</form>
<script type="text/javascript">
function GROUPS_validate_data_onsubmit()
{
var msg;
var empty_fields = "";
var errors = "";
while (document.GROUP_EDIT_FORM.GROUP_NAME.value.substring(0,1) == " ")
{
document.GROUP_EDIT_FORM.GROUP_NAME.value = document.GROUP_EDIT_FORM.GROUP_NAME.value.substring(1);
}
if (document.GROUP_EDIT_FORM.GROUP_NAME.value == "")
{
empty_fields += "\n Group Name";
}
if (document.GROUP_EDIT_FORM.GROUP_NAME.value.length > 200)
{
errors += "The Group Name field cannot exceed 200 characters\n"
document.GROUP_EDIT_FORM.GROUP_NAME.value = document.GROUP_EDIT_FORM.GROUP_NAME.value.substring(0,199);
}
if (document.GROUP_EDIT_FORM.TEAM_ID.options[document.GROUP_EDIT_FORM.TEAM_ID.selectedIndex].value == "")
{
empty_fields += "\n Team";
}
if (!empty_fields && !errors)
{
return true;
}
msg = "__________________________________________________\n\n";
msg += "The form was not submitted because of the following errors.\n";
msg += "Please correct these errors and re-submit.\n";
msg += "__________________________________________________\n\n";
if (empty_fields)
{
msg += "- The following required fields are empty:"
+ empty_fields + "\n";
}
msg += errors + "\n";
msg += "__________________________________________________\n\n";
alert (msg);
return false;
}
function updateGroup(groupSeq){
var docPane = dojo.widget.byId("workingDIV");
docPane.bindArgs = {preventCache: true};
var localGroupName = document.GROUP_EDIT_FORM.GROUP_NAME.value;
var localGroupTeam = document.GROUP_EDIT_FORM.TEAM_ID.options[document.GROUP_EDIT_FORM.TEAM_ID.selectedIndex].value;
if ((!groupSeq) && (!localGroupName)){
docPane.setContent("Data missing");
}else{
docPane.setUrl('act_GroupUpdate.cfm?KEY_COURSE_GROUP_SEQ='+groupSeq+'&GROUP_NAME='+localGroupName+'&TEAM_ID='+localGroupTeam+'&#session.UrlToken#');
}
}
</script>
So I'm totlly stuck on this and can't figure it out.
I've got a button on a form and it's supposed to call two functions.
1) A form validation
2) A function to call dojo to load the next page and do some other stuff.
<input type="button" value="Save" onclick="GROUPS_validate_data_onsubmit(); return true; updateGroup(37);">
Now I'm pretty sure the 'return true' is out of place..?? It works if I take the second function (updateGroup) out all together...
What's happening now (if I leave 'return true' out), is that the validation function will fire, but then when I correct the error, none of the funtions seem to fire.. or at least the updateGroups doesn't..
So any ideas on what I'm doing wrong?
Code below:
----------------------------------------------
<form name="GROUP_EDIT_FORM" method="post">
<input type="Text" name="GROUP_NAME" value="">
<SELECT name="TEAM_ID">
<OPTION value="">
<OPTION value="1">Team
</select>
<input type="button" value="Save" onclick="GROUPS_validate_data_onsubmit(); return true; updateGroup(37);">
</form>
<script type="text/javascript">
function GROUPS_validate_data_onsubmit()
{
var msg;
var empty_fields = "";
var errors = "";
while (document.GROUP_EDIT_FORM.GROUP_NAME.value.substring(0,1) == " ")
{
document.GROUP_EDIT_FORM.GROUP_NAME.value = document.GROUP_EDIT_FORM.GROUP_NAME.value.substring(1);
}
if (document.GROUP_EDIT_FORM.GROUP_NAME.value == "")
{
empty_fields += "\n Group Name";
}
if (document.GROUP_EDIT_FORM.GROUP_NAME.value.length > 200)
{
errors += "The Group Name field cannot exceed 200 characters\n"
document.GROUP_EDIT_FORM.GROUP_NAME.value = document.GROUP_EDIT_FORM.GROUP_NAME.value.substring(0,199);
}
if (document.GROUP_EDIT_FORM.TEAM_ID.options[document.GROUP_EDIT_FORM.TEAM_ID.selectedIndex].value == "")
{
empty_fields += "\n Team";
}
if (!empty_fields && !errors)
{
return true;
}
msg = "__________________________________________________\n\n";
msg += "The form was not submitted because of the following errors.\n";
msg += "Please correct these errors and re-submit.\n";
msg += "__________________________________________________\n\n";
if (empty_fields)
{
msg += "- The following required fields are empty:"
+ empty_fields + "\n";
}
msg += errors + "\n";
msg += "__________________________________________________\n\n";
alert (msg);
return false;
}
function updateGroup(groupSeq){
var docPane = dojo.widget.byId("workingDIV");
docPane.bindArgs = {preventCache: true};
var localGroupName = document.GROUP_EDIT_FORM.GROUP_NAME.value;
var localGroupTeam = document.GROUP_EDIT_FORM.TEAM_ID.options[document.GROUP_EDIT_FORM.TEAM_ID.selectedIndex].value;
if ((!groupSeq) && (!localGroupName)){
docPane.setContent("Data missing");
}else{
docPane.setUrl('act_GroupUpdate.cfm?KEY_COURSE_GROUP_SEQ='+groupSeq+'&GROUP_NAME='+localGroupName+'&TEAM_ID='+localGroupTeam+'&#session.UrlToken#');
}
}
</script>