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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up about dynamic drop list

    help needed!! I need code that creates a drop list , once a user selected a choice like name from the drop list. An onchange event occurs that brings up 3 textfields that allow the user to enter/type in firstname middlename and lastname.

    thanks

  • #2
    New Coder
    Join Date
    Jun 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Any help out there with this question?

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,519
    Thanks
    3
    Thanked 507 Times in 494 Posts
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <style type="text/css">
    /*<![CDATA[*/
    .FrmDiv {
      position:absolute;visibility:hidden;width:200px;
    }
    
    /*]]>*/
    </style>
    
    <script language="JavaScript" type="text/javascript">
    /*<![CDATA[*/
    
    var SelAry=[];
    SelAry[0]=['Select IP',''];
    SelAry[1]=['Name IP','nameip'];
    SelAry[2]=['Phone IP','phoneip'];
    
    function Populate(id,ary,fun){
     var sel=document.getElementById(id)
     for (var zxc0=0;zxc0<ary.length;zxc0++){
      sel.options[zxc0]=new Option(ary[zxc0][0],ary[zxc0][1],true,true);
     }
     sel.selectedIndex=0;
     sel.onchange=function(){ window[fun](this); }
    }
    
    function CngIP(obj){
     var ipobj;
     if (obj.ipobj){
      obj.ipobj.style.visibility='hidden';
     }
     if (obj.value){
      ipobj=obj.form[obj.value].parentNode;
      ipobj.style.visibility='visible';
      ipobj.style.left=(zxcPos(obj)[0]+100)+'px';
      ipobj.style.top=(zxcPos(obj)[1])+'px';
     }
     obj.ipobj=ipobj;
    }
    
    function zxcPos(zxcobj){
     zxclft=zxcobj.offsetLeft;
     zxctop=zxcobj.offsetTop;
     while(zxcobj.offsetParent!=null){
      zxcpar=zxcobj.offsetParent;
      zxclft+=zxcpar.offsetLeft;
      zxctop+=zxcpar.offsetTop;
      zxcobj=zxcpar;
     }
     return [zxclft,zxctop];
    }
    
    
    /*]]>*/
    </script>
    
    </head>
    
    <body onload="Populate('IPSel',SelAry,'CngIP')">
    <br /><br />
    
    <center><form>
    <select id="IPSel" name=IPSel" ></select>
    <div class="FrmDiv">
    Name <input type=text name="nameip"  />
    </div>
    <div class="FrmDiv">
    Phone <input type=text name="phoneip"  />
    </div>
    </form>
    </center></body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #4
    New Coder
    Join Date
    Jun 2006
    Posts
    46
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    thank you very much , life saver...


  •  

    Posting Permissions

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