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
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    action select not working

    I am trying to get my action page to work where if
    the user selects yes to Employee radio button then it goes to a certain page,
    if not it goes to another page. It doesnt do anything on submit and when I do an alert on alert(document.myFrm.employee.action) for test only form submit it gives me Undefined message.

    Please advise what I am doing wrong?
    Code:
    function mySelection()
    {
    	if(document.myFrm.employee.value == "yes")
    	{
    		document.myFrm.employee.action='gotoEmployee.cfm';
    	}
    	else
    	{
    		document.myFrm.employee.action='secondPage.cfm';
    	}
    }
    
    ...
    <form name="myFrm" method="post" onSubmit="return mySelection();">
    <input name="employee" type="radio" value="yes"> 
    <input name="employee" type="radio" value="no"> 
    ...

  • #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
    The form has an action, not the form element.

    i.e.
    document.myFrm.action='gotoEmployee.cfm';

    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
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    Try it this way

    Code:
    function mySelection(){
    	if(document.myFrm.employee[0].checked){
    	document.myFrm.employee.action='gotoEmployee.cfm';
    	}
    	else{
    	document.myFrm.employee.action='secondPage.cfm';
    	}
    }
    The silent one.

    The most dangerous thing in the world is an idea.
    The most dangerous person in the world is the one with an idea.


  •  

    Posting Permissions

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