Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Nov 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Edit onclick function to redirect to different url?

    Hi,

    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.

    Code:
    function submitIt() {
    var f = document.editFrm;
    var msg = '';
    
    if (f.project_name.value.length < 3) {
        msg += "\n<?php echo $AppUI->_('projectsValidName', UI_OUTPUT_JS);?>";
        f.project_name.focus();
    }
    if (f.project_color_identifier.value.length < 3) {
        msg += "\n<?php echo $AppUI->_('projectsColor', UI_OUTPUT_JS);?>";
        f.project_color_identifier.focus();
    }
    if (f.project_company.options[f.project_company.selectedIndex].value < 1) {
        msg += "\n<?php echo $AppUI->_('projectsBadCompany', UI_OUTPUT_JS);?>";
        f.project_name.focus();
    }
    /*
    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) {
        f.submit();
    } else {
        alert(msg);
    }
    }

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    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.

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Nov 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •