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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Select Box Script not working with forms

    I am using a javascript given to be by a helpful member (vwphillips). The code works great, but I am not getting the data tranferred into my forms. So from the users standpoint everything works great but on my side when I receive the completed form I don't get the data they selected. I am using FrontPage and the rest of the form is working fine. The page with an example of this problem is www.affordyourbills.com/example.htm
    When the user selects their "home value" the other options are generated. But once I get the completed form the only values that are missing are options generated by the code. If the user chooses not the select the other options, then the "Select One" is transmitted to me.
    Here is the code that I originally began with... the code with options is too large to post, but is on the previously mentioned link.
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
    <title></title>
    <script language="JavaScript" type="text/javascript">
    <!--
    var Ary1=[];
    Ary1[1]=['Topic 1','Topic 2'];
    Ary1[2]=['Topic 3','Topic 4'];
    
    function Populate(obj,ary,sela,selb){
    var args=Populate.arguments;
    var index=args[0].selectedIndex;
    if (index<1){ return; }
    for (var zxc0=2;zxc0<args.length;zxc0++){
    var sel=document.getElementById(args[zxc0]);
    sel.options.length=0;
    sel.options[0]=new Option('Select','',true,true);
    for (var zxc1=0;zxc1<ary[index].length;zxc1++){
    sel.options[zxc1+1]=new Option(ary[index][zxc1],'',true,true);
    }
    sel.selectedIndex=0;
    }
    }
    //-->
    </script>
    
    </head>
    
    <body>
    <select onclick="Populate(this,Ary1,'Sel2','Sel3');" >
    <option >Select</option>
    <option >List 1</option>
    <option >List 2</option>
    </select>
    <select id="Sel2">
    <option >EMPTY</option>
    </select>
    <select id="Sel3">
    <option >EMPTY</option>
    </select>
    </body>
    
    </html>
    Thank you for any help!!!
    Jeremy

  • #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
    Select elements must have a name attribute to be passed on via a form to most back-end things, IIRC.
    Try giving them names.
    A simple test here confirms that the value is not passed in the URL via GET if you remove the name attribute. I assume POST is the same.

    Code:
    <form>
    <select id="sel_1" name="sel_1">
    <option value='1'>1</option>
    <option value='1'>2</option>
    <option value='1'>3</option>
    <option value='1'>4</option>
    </select>
    <input type="submit">
    </form>

    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
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the response. In my actual page I believe I have each entry named, but I may not be interpretting this correctly. Here is an example of the code
    Code:
    <select id="Sel2" name="D2" size="1" style="width: 165; height: 22">
    <option >Select One</option>
    </select>
    I tried changing the name of the field to "Sel2" instead of "D2", but that didn't have any effect.

  • #4
    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
    Ok; change the method of the form to GET, so you see the values in the URL.
    Pop in some values and submit it.
    Do you see the values that you selected in the URL? If so, the problem is the back-end Frontpage stuff. If not, it's something in the front-end script or HTML.

    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/

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think it is FrontPage. When I change the method to GET, it immediately changes it back to POST when I save changes. It looks like I may have to pursue another method to get these forms to submit all the information correctly. Thank you for your help!


  •  

    Posting Permissions

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