SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hidden form fields

    I have created a simple html form that uses mailscript.cgi. My problem is this: the form asks the user to pick a specific location and based on that location the email is sent to a specific person. I created a function that would input the choices and runs a select statement to choose the correct email address. My problem is that I have try to send that information into the hidden recipient field and it is not working. Here is my coding:

    Code:
    <!--
    
    function get_Loc() {
     	
    	item_index=document.inquiry.location.selectedIndex;
    	item_value=document.inquiry.location.options[item_index].value;
      
        Select Case (item_value) 
    	 Case "Allentown"
    	  document.inquiry.recipient.value="dweaver@phoebe.org"
    	 Case "Berks"
    	  document.inquiry.recipient.value="rwade@phoebe.org"
    	 Case "Richland"
    	  document.inquiry.recipient.value="mkethley@phoebe.org"
    	End Select 
    	
    		
    }
    //-->
    
    <td height="15" colspan="4" align="left" valign="top"><font size="2" face="Arial, Helvetica, sans-serif"><strong>Check 
                        which campus you have interest in applying for: * </strong> 
                        <select name="location" onClick="get_Loc(this)">
                          <option value="Allentown">Allentown
                          <option value="Berks">Berks
                          <option value="Richland">Richland
                        </select>
    My 1st question is when we use this code: <input type=hidden name=recipient value=>
    Can I input a field in place of the value?
    Should I or Can I call the function from within the code <input type=hidden name=recipient value=get_Loc("document.inquiry.location.value")> instead of calling it from the select area? This seems to be so simple and I can't figure it out. Is there any other ways of running this code? Any help would be great.

  2. #2
    SitePoint Enthusiast icovey's Avatar
    Join Date
    Jul 2006
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, that function in the input doesn't look to good to me. I'd stick with what you have but try changing your event trigger to onChange rather than onClick.

    If this doesn't work try debugging with alert() in your script to see where it's falling over.

    Cheers,
    Cheers,
    Ian.

    7879 | Web Marketing Lichfield

  3. #3
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I made the change and it is giving me the following error:
    Object excepted on line 102.

    <select name="location" onChange="get_Loc()">
    <option value=""> </option>
    <option value="Allentown">Allentown </option>
    <option value="Berks">Berks </option>
    <option value="Richland">Richland </option>
    </select>

    I ran it 2 ways; once with "this" in the parathensis and the other without.

    function get_Loc() {

    var item_index=document.inquiry.location.selectedIndex;
    var item_value=document.inquiry.location.options[item_index].value;

    Select Case (item_value)
    Case ("Allentown")
    document.inquiry.recipient.value = "dweaver@phoebe.org";
    break;
    Case ("Berks")
    document.inquiry.recipient.value = "tazdw4@yahoo.com";
    break;
    Case ("Richland")
    document.inquiry.recipient.value = "tazdw4@aol.com";
    break;
    Case default:
    document.inquiry.recipient.value = "tazdw4@ispey.com"
    End Select

    }
    The function actually gets the item within the function. Is that the proper way of doing this?

  4. #4
    SitePoint Enthusiast icovey's Avatar
    Join Date
    Jul 2006
    Posts
    77
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey tazdw4

    Which line of the code is line 102?

    Cheers,
    Cheers,
    Ian.

    7879 | Web Marketing Lichfield

  5. #5
    SitePoint Member
    Join Date
    Sep 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I posted another question. I was able to fix the original problem with the object excepted error. I am having difficulty passing values to the recipient field.


Bookmarks

Posting Permissions

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