What would this be called

Discussion in 'JavaScript' started by NaNar, Sep 6, 2007.

  1. #1
    Hi.

    Sorry but I am a non-techie person, so forgive me with the bad description I am about to begin....

    I have a network of sites. And each time I add a new one, I have to go through each site and add the link for use with the drop down menu.

    I would like to make a list on the main site and then on each network site use some js code to call that list on the main site. Thus only having to add the new sites onto one file instead of many and many.

    Thanks to anyone that can direct me to this!
     
    NaNar, Sep 6, 2007 IP
  2. bibel

    bibel Active Member

    Messages:
    289
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #2
    It depends on what sort of drop down menu you use. If it reads the links from an javascript array, then it's easy. Just make an "links.js" file on your main website, with the array of links, and include that file on all the other sites with
    <script src="http://www.your_main_site.com/links.js"></script>
     
    bibel, Sep 6, 2007 IP
    shadey likes this.
  3. NaNar

    NaNar Prominent Member

    Messages:
    4,215
    Likes Received:
    275
    Best Answers:
    0
    Trophy Points:
    300
    #3
    Hi, I would need to create an array as this is just using a form -- how would i do that (create the array)

    
    <form name="guideform" id="guideform" action="#"> 
    <select name="guidelinks" id="guidelinks" onChange="window.location=document.guideform.guidelinks.options[document.guideform.guidelinks.selectedIndex].value"> 
    Code (markup):
     
    NaNar, Sep 7, 2007 IP
  4. NaNar

    NaNar Prominent Member

    Messages:
    4,215
    Likes Received:
    275
    Best Answers:
    0
    Trophy Points:
    300
    #4
    I have come across this....

    How would I name the code so I could call it from other websites (like stated in bibel post).

    
    This is the code for the form
    
    <form name="Form1">
    <br / name="selURL" onChange="NavTo(selURL)" style="width:200px">
       <option selected value="0"> --Select--</option>
       <option value="http://www.SwansonSoftware.com">SwansonSoftware</option>
       <option value="http://www.google.com">Google</option>
    </br />
    </form>
    
    Here is the Javascript
    
    <script language="JavaScript" type="text/javascript">
    
       <!--
       function NavTo(sel)
       {
          var myindex=sel.selectedIndex
          if (myindex != 0){
             location=sel.options[myindex].value;
          }
       }
       // -->
    
    </script>
    
    Code (markup):
     
    NaNar, Sep 7, 2007 IP
  5. bibel

    bibel Active Member

    Messages:
    289
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #5
    Now it's more clear what you want.

    There' no need for that code you posted.
    In onchange just add "if(this.value){window.location=this.value}".

    As for filling the options from a script from another site, with this method it's a bit more complicated. An easy way would be to put your entire combo in a file on the main website, say http://www.your_main_website.com/links_list.html

    In that file put this :

    <select name="selURL" onChange="NavTo(selURL)" style="width:200px">
    <option selected value="0"> --Select--</option>
    <option value="http://www.SwansonSoftware.com">SwansonSoftware</option>
    <option value="http://www.google.com">Google</option>
    </select>

    (I'll presume that <br in your code is a typo :) )

    Next, in your other websites you can get that select with :

    $combo=file_get_contents("http://www.your_main_website.com/links_list.html");

    and then echo $combo, wherever you want your links
     
    bibel, Sep 7, 2007 IP
  6. NaNar

    NaNar Prominent Member

    Messages:
    4,215
    Likes Received:
    275
    Best Answers:
    0
    Trophy Points:
    300
    #6
    Going to give it a whirl :)
    The br was just a copy and paste....so...

    When you say echo I add "echo $combo" where I want the box to be?

     
    NaNar, Sep 7, 2007 IP
  7. NaNar

    NaNar Prominent Member

    Messages:
    4,215
    Likes Received:
    275
    Best Answers:
    0
    Trophy Points:
    300
    #7
    Hi bibel, not having any luck.
     
    NaNar, Sep 7, 2007 IP
  8. bibel

    bibel Active Member

    Messages:
    289
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #8
    what's not working ?
    give me the url of the combo html
     
    bibel, Sep 7, 2007 IP
  9. NaNar

    NaNar Prominent Member

    Messages:
    4,215
    Likes Received:
    275
    Best Answers:
    0
    Trophy Points:
    300
    #9
    Hey bibel -- green rep your way for helping me out. Actually got it working, using js :)

    Thanks a lot!
     
    NaNar, Sep 7, 2007 IP