Web Analytics Made Easy -
StatCounter Double Combo opening in iframe--HELP!!! - CodingForum

Announcement

Collapse
No announcement yet.

Double Combo opening in iframe--HELP!!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Double Combo opening in iframe--HELP!!!

    Hi,

    I admit I'm a complete newb and I need help!

    I need the following script to open in an iframe on the same page (instead of a new page, which is what it is doing as it is)

    If there is anyone who can make the necessary adjustments to the code below, it would be much appreciated!

    _______________________________________________________________


    <form name="doublecombo">
    <p align="center">
    <select name="example" size="1" onChange="redirect(this.options.selectedIndex)">

    <option>choice 1</option>
    <option>choice 2</option>
    <option>choice 3</option>

    </select>

    <select name="stage2" size="1">
    <option>Please Select</option>
    <option value="http://www.news.com">News.com</option>
    </select>
    <input type="button" name="test" value="Go!"
    onClick="go()">
    </p>

    <p align="center">&nbsp;</p>

    <script language="javascript">

    var groups=document.doublecombo.example.options.length
    var group=new Array(groups)
    for (i=0; i<groups; i++)
    group[i]=new Array()

    group[0][0]=new Option("Please Choose","")
    group[0][1]=new Option("News.com","http://www.news.com")

    group[1][0]=new Option("Please Choose","")
    group[1][1]=new Option("ABC News","http://www.abcnews.com")

    group[2][0]=new Option("Please Choose","")
    group[2][1]=new Option("iTunes","http://www.itunes.com")

    var temp=document.doublecombo.stage2

    function redirect(x){
    for (m=temp.options.length-1;m>0;m--)
    temp.options[m]=null
    for (i=0;i<group[x].length;i++){
    temp.options[i]=new Option(group[x][i].text,group[x][i].value)
    }
    temp.options[0].selected=true
    }

    function go(){
    location=temp.options[temp.selectedIndex].value
    }
    //-->
    </script>

    </form>

  • #2
    I should think it's your "go" function -- it's changing your location.

    I think what you should do is to put an iframe on your doc like this:

    Code:
    <iframe src="www.codingforum.net" id="myframe" name="myframe"></iframe>
    Then use your "go" to reset the src.

    Code:
    function go(){
      var myIframe = document.getElementById("myframe");
      myIframe.src = temp.options[temp.selectedIndex].value;
    }
    Of course, I haven't tried it.

    Comment


    • #3
      try this, already tested.


      <html>

      <head>
      <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
      <meta name="ProgId" content="FrontPage.Editor.Document">
      <meta http-equiv="Content-Type" content="text/html; charset=windows-1254">
      <title>Yeni Sayfa 1</title>
      </head>

      <body>
      <form name="doublecombo">
      <p><select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
      <option>Technology Sites</option>
      <option>News Sites</option>
      <option>Search Engines</option>
      </select>
      <select name="stage2" size="1">
      <option value="http://www.google.com">google.com</option>
      <option value="http://www.news.com">News.com</option>
      <option value="http://www.wired.com">Wired News</option>
      </select>
      <input type="button" name="test" value="Go!"
      onClick="go()">
      </p>

      <script>
      <!--



      var groups=document.doublecombo.example.options.length
      var group=new Array(groups)
      for (i=0; i<groups; i++)
      group[i]=new Array()

      group[0][0]=new Option("icdenetim","http://icdenetim.googlepages.com")
      group[0][1]=new Option("News.com","http://www.news.com")
      group[0][2]=new Option("Wired News","http://www.wired.com")

      group[1][0]=new Option("CNN","http://www.cnn.com")
      group[1][1]=new Option("ABC News","http://www.abcnews.com")

      group[2][0]=new Option("Hotbot","http://www.hotbot.com")
      group[2][1]=new Option("Infoseek","http://www.infoseek.com")
      group[2][2]=new Option("Excite","http://www.excite.com")
      group[2][3]=new Option("Lycos","http://www.lycos.com")

      var temp=document.doublecombo.stage2

      function redirect(x){
      for (m=temp.options.length-1;m>0;m--)
      temp.options[m]=null
      for (i=0;i<group[x].length;i++){
      temp.options[i]=new Option(group[x][i].text,group[x][i].value)
      }
      temp.options[0].selected=true
      }

      function go(){
      document.getElementById('CER').src=temp.options[temp.selectedIndex].value
      }
      //-->
      </script>


      <iframe src="http://www.dynamicdrive.com" id="CER" width="665" height="335" name="CER"></iframe>
      </form>
      </body>

      </html>

      Comment


      • #4
        Thx for the help guys!!

        It's now working and showing up each page in the iframe!!

        I've discovered a bug though!!

        I have 3 options in the 1st box

        1 USA
        2 Other Countries
        3 Online

        When each 1 is clicked, the relevant list of options shows up in the 2nd and when these are clicked on it opens up in the iframe!

        Problem is this:

        After clicking say "USA" and then choosing from any of the options in the corresponding second box to look at (list of 52 States)....then clicking on say "other countries" and then choosing options from second box for that category (list of 33 countries)...everything is fine!! But if I go back and click on "USA" in the 1st box again and then go to choose a state in the 2nd box with the list of states...It is empty!!! The list of states is GONE!!!

        I have to refresh the page in order to get the list in the 2nd box to show up again!!

        Anyone have any ideas what is goung on and how to fix this????

        Comment

        Working...
        X