View Full Version : Edit onclick function to redirect to different url?

01-20-2006, 05:23 PM

I'm trying to edit a project data form in which the submit button is associated with the function below (through onclick). As far as I can tell, this function saves to the database all the information in the form and then redirects me to the "view project" page. Is there a way to edit this function so that after clicking the submit button it will still save all the data but take me to a different page (of my choice)? Thanks.

function submitIt() {
var f = document.editFrm;
var msg = '';

if (f.project_name.value.length < 3) {
msg += "\n<?php echo $AppUI->_('projectsValidName', UI_OUTPUT_JS);?>";
if (f.project_color_identifier.value.length < 3) {
msg += "\n<?php echo $AppUI->_('projectsColor', UI_OUTPUT_JS);?>";
if (f.project_company.options[f.project_company.selectedIndex].value < 1) {
msg += "\n<?php echo $AppUI->_('projectsBadCompany', UI_OUTPUT_JS);?>";
if (f.project_end_date.value > 0 && f.project_end_date.value < f.project_start_date.value) {
msg += "\n<?php echo $AppUI->_('projectsBadEndDate1');?>";
if (f.project_actual_end_date.value > 0 && f.project_actual_end_date.value < f.project_start_date.value) {
msg += "\n<?php echo $AppUI->_('projectsBadEndDate2');?>";
if (msg.length < 1) {
} else {

01-20-2006, 08:01 PM
All this does is check some values (validate) then submit the form.
So it ends up going to the form's action page. You'd have to modify the action page to redirect when it's finished if that's the behavior you wanted.
Or you could have it submit to another window/frame, etc instead.
There's no magic here, though. It's just a basic form submission with a little validation.

01-23-2006, 05:41 PM
You're absolutely right. I guess I should have spent some more time looking at the code, but in my newbieness, I thought that the problem was with that function. Thanks a lot!