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 7 of 7
  1. #1
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Passing parent's select to child's form

    I need to make a select in a parent's form exactly like a select in a child's form onchange.
    See the post below...I think I'm close.
    Thanks
    Last edited by zoobie; 10-05-2003 at 05:00 AM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,076
    Thanks
    11
    Thanked 98 Times in 96 Posts
    Hi , you can do this via javascript so I am moving you to that forum.
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ok...
    I've put the exact same select dropdown into the child's form
    with a style="display:none" which seems to work.
    The one in bold is for the child but not working at all.
    Maybe I have them backward or there's a better way.
    Fix? Thanks
    Code:
    window.onload = function(){
    document.sara.sty.onchange = function(){
      comments.document.forms[0].sam.className=this.options[this.selectedIndex].value;
    comments.document.forms[0].sty.options[document.selectedIndex].value=this.options[this.selectedIndex].value;
     }
    }
    Last edited by zoobie; 10-05-2003 at 07:59 AM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #4
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Ha ha! I go to Las Vegas for a week and this still hasn't been answered...Oh well, I turn it around then. Thanks
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">

  • #5
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    try

    comments.document.forms[0].sty.options[document.forms[0].sty.selectedIndex]value= ....
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #6
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts

    If I understood you correctly...

    What you were trying to do was set the select's value not its selectedIndex...

    If both selects have the same option items in the same order,
    just set the parent select's selectedIndex to the current select's.
    Code:
    window.onload = function(){
    document.sara.sty.onchange = function(){
      var parentForm = comments.document.forms[0];
      parentForm.sam.className=this.options[this.selectedIndex].value;
      parentForm.sty.selectedIndex=this.selectedIndex
     }
    }
    If not, you need to search for it:
    Code:
    window.onload = function(){
    document.sara.sty.onchange = function(){
      var parentForm = comments.document.forms[0];
      parentForm.sam.className=this.options[this.selectedIndex].value;
      var parentSelect = parentForm.sty;
      var searchString = this.options[this.selectedIndex].value;
      for (var i=0;i<parentSelect.options.length;i++){
        if (parentSelect.options[i].value==searchString){
          parentSelect.selectedIndex=i;
          break;
        }
      }
     }
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    ColoRockyz
    Posts
    1,646
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Exactly...Thanks.
    Last edited by zoobie; 10-11-2003 at 09:29 PM.
    Zoobie or not Zoobie...That is the problem.
    <body onUnload="flush( ! )">


  •  

    Posting Permissions

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