Multiple Check Boxes URL Jump TIA

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tim

    #1

    Multiple Check Boxes URL Jump TIA

    Hello All!

    I'm having a difficult problem and I'm wondering if anyone can help.
    Here's the deal.

    I have a webpage with multiple forms on it. All of the forms have drop
    down boxes that when selected and the corresponding button is pressed, the
    user should be taken to a new website.

    However, since I have 41 forms and 41 corresponding checkboxes, I would
    like one function that can manage the 41 different forms.

    Here's what I've tried so far, but it doesn't work. drop_num would be
    the number of the form involved. In this case, all 41 forms are named as
    follows: the first form is named Form1, the second Form2 and so forth all
    the way till Form41. The drop down boxes are named as follows: the first
    WebPage1, second WebPage2, etc.

    The buttons activate the ChangeURL function with the OnClick() function.

    function ChangeURL(drop_ num)
    {
    if (navigator.appN ame.indexOf('Ne tscape') > -1) {
    location.href = drop_num + "." + "WebPage" + drop_num + "." + "options["
    + drop_num + "." + "WebPage" + drop_num + "." + "selectedIn dex].value";
    }
    else {
    location.href = drop_num + "." + "WebPage" + drop_num + "." + "value";
    }
    }

    Thanks in advance,

    Tim



  • Lasse Reichstein Nielsen

    #2
    Re: Multiple Check Boxes URL Jump TIA

    "Tim" <mrsterious@yah oo.com> writes:
    [color=blue]
    > function ChangeURL(drop_ num)
    > {
    > if (navigator.appN ame.indexOf('Ne tscape') > -1) {[/color]

    That matches both Netscape 4 and Netscape 7, where Netscape 7 does have
    the value directly on the select element.
    [color=blue]
    > location.href = drop_num + "." + "WebPage" + drop_num + "." + "options["
    > + drop_num + "." + "WebPage" + drop_num + "." + "selectedIn dex].value";[/color]

    I assume the value of the option is the URL of the new page. Here, you
    just create a string that ends in ".value", not the URL that it refers
    to.

    Try:

    var sel = document.forms['Form'+drop_num].elements['WebPage'+drop_ num];
    location.href = sel.options[sel.selectedInd ex].value;

    If you want to support Netscape 4, you might as well *just* use the
    above. It still works on all the newer browsers that also have the
    value on the select element.

    /L
    --
    Lasse Reichstein Nielsen - lrn@hotpop.com
    Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
    'Faith without judgement merely degrades the spirit divine.'

    Comment

    • Egbert Beuker

      #3
      Re: Multiple Check Boxes URL Jump TIA

      Why don't you put the form object into the function?
      You can name all the listboxes the same then!

      function changeURL(frm)
      {
      window.navigate (frm.webpagedro pdown.value)
      }

      <form id="form1">
      <select id="webpagedrop down">
      [options go here]
      </select>
      <button onclick="change URL(this.form)" >
      </form>

      <form id="form2">
      <select id="webpagedrop down">
      [options go here]
      </select>
      <button onclick="change URL(this.form)" >
      </form>

      "Tim" <mrsterious@yah oo.com> wrote in message
      news:jyO8b.6805 8$IJ6.2022888@t wister.socal.rr .com...[color=blue]
      > Hello All!
      >
      > I'm having a difficult problem and I'm wondering if anyone can help.
      > Here's the deal.
      >
      > I have a webpage with multiple forms on it. All of the forms have drop
      > down boxes that when selected and the corresponding button is pressed, the
      > user should be taken to a new website.
      >
      > However, since I have 41 forms and 41 corresponding checkboxes, I[/color]
      would[color=blue]
      > like one function that can manage the 41 different forms.
      >
      > Here's what I've tried so far, but it doesn't work. drop_num would be
      > the number of the form involved. In this case, all 41 forms are named as
      > follows: the first form is named Form1, the second Form2 and so forth all
      > the way till Form41. The drop down boxes are named as follows: the first
      > WebPage1, second WebPage2, etc.
      >
      > The buttons activate the ChangeURL function with the OnClick()[/color]
      function.[color=blue]
      >
      > function ChangeURL(drop_ num)
      > {
      > if (navigator.appN ame.indexOf('Ne tscape') > -1) {
      > location.href = drop_num + "." + "WebPage" + drop_num + "." +[/color]
      "options["[color=blue]
      > + drop_num + "." + "WebPage" + drop_num + "." + "selectedIn dex].value";
      > }
      > else {
      > location.href = drop_num + "." + "WebPage" + drop_num + "." + "value";
      > }
      > }
      >
      > Thanks in advance,
      >
      > Tim
      >
      >
      >[/color]


      Comment

      • Tim

        #4
        Re: Multiple Check Boxes URL Jump TIA

        Egbert,

        Thank you! It works perfectly!

        Tim
        [color=blue]
        > Why don't you put the form object into the function?
        > You can name all the listboxes the same then!
        >
        > function changeURL(frm)
        > {
        > window.navigate (frm.webpagedro pdown.value)
        > }
        >
        > <form id="form1">
        > <select id="webpagedrop down">
        > [options go here]
        > </select>
        > <button onclick="change URL(this.form)" >
        > </form>
        >
        > <form id="form2">
        > <select id="webpagedrop down">
        > [options go here]
        > </select>
        > <button onclick="change URL(this.form)" >
        > </form>
        >
        > "Tim" <mrsterious@yah oo.com> wrote in message
        > news:jyO8b.6805 8$IJ6.2022888@t wister.socal.rr .com...[color=green]
        > > Hello All!
        > >
        > > I'm having a difficult problem and I'm wondering if anyone can help.
        > > Here's the deal.
        > >
        > > I have a webpage with multiple forms on it. All of the forms have[/color][/color]
        drop[color=blue][color=green]
        > > down boxes that when selected and the corresponding button is pressed,[/color][/color]
        the[color=blue][color=green]
        > > user should be taken to a new website.
        > >
        > > However, since I have 41 forms and 41 corresponding checkboxes, I[/color]
        > would[color=green]
        > > like one function that can manage the 41 different forms.
        > >
        > > Here's what I've tried so far, but it doesn't work. drop_num would[/color][/color]
        be[color=blue][color=green]
        > > the number of the form involved. In this case, all 41 forms are named as
        > > follows: the first form is named Form1, the second Form2 and so forth[/color][/color]
        all[color=blue][color=green]
        > > the way till Form41. The drop down boxes are named as follows: the first
        > > WebPage1, second WebPage2, etc.
        > >
        > > The buttons activate the ChangeURL function with the OnClick()[/color]
        > function.[color=green]
        > >
        > > function ChangeURL(drop_ num)
        > > {
        > > if (navigator.appN ame.indexOf('Ne tscape') > -1) {
        > > location.href = drop_num + "." + "WebPage" + drop_num + "." +[/color]
        > "options["[color=green]
        > > + drop_num + "." + "WebPage" + drop_num + "." + "selectedIn dex].value";
        > > }
        > > else {
        > > location.href = drop_num + "." + "WebPage" + drop_num + "." +[/color][/color]
        "value";[color=blue][color=green]
        > > }
        > > }
        > >
        > > Thanks in advance,
        > >
        > > Tim
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...