Popup and set data?

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

    Popup and set data?


    I'm trying to open a popup window and then set some data, but I can't
    seem to make it work. I'm sure I'm missing something obvious.

    popwin = document.open(' mypop.html', \"external\" , \"width=\" + w
    +\",height=\" + h +
    \",resizable=no ,scrollbars=no, status=yes,loca tion=no,toolbar =no,menubar=no\ ");
    popwin.document .data.user=user ;

    mypop.html has a <form name=data> with an element named "user" in it.
    Essentially, I want to be able to pop up a window with some populated
    data in it, but I can't figure out how I can do it.

    Thanks.

    -Greg G
  • kaeli

    #2
    Re: Popup and set data?

    In article <V-Sdnbfg9pEGx93fR Vn-hg@ctc.net>, ggershSNACK@CAK Ectc.net
    enlightened us with...[color=blue]
    >
    > I'm trying to open a popup window and then set some data, but I can't
    > seem to make it work. I'm sure I'm missing something obvious.
    >
    > popwin =[/color]

    window.open.
    Not document.open.
    [color=blue]
    > document.open(' mypop.html', \"external\" , \"width=\" + w
    > +\",height=\" + h +
    > \",resizable=no ,scrollbars=no, status=yes,loca tion=no,toolbar =no,menubar=no\ ");[/color]

    The window has to load first before you can access the document. You may need
    a setTimeout before you try this:[color=blue]
    > popwin.document .data.user=user ;[/color]


    --
    --
    ~kaeli~
    A lot of money is tainted - It taint yours and it taint mine.



    Comment

    • Greg G

      #3
      Re: Popup and set data?

      kaeli wrote:[color=blue]
      > In article <V-Sdnbfg9pEGx93fR Vn-hg@ctc.net>, ggershSNACK@CAK Ectc.net
      > enlightened us with...
      >[color=green]
      >>I'm trying to open a popup window and then set some data, but I can't
      >>seem to make it work. I'm sure I'm missing something obvious.
      >>
      >>popwin =[/color]
      >
      >
      > window.open.
      > Not document.open.[/color]

      That was the latest iteration I had tried. It's strange, but
      document.open worked the same as window.open. Or at least, it did visually.

      [color=blue][color=green]
      >>document.open ('mypop.html', \"external\" , \"width=\" + w
      >>+\",height= \" + h +
      >>\",resizable= no,scrollbars=n o,status=yes,lo cation=no,toolb ar=no,menubar=n o\");[/color]
      >
      >
      > The window has to load first before you can access the document. You may need
      > a setTimeout before you try this:
      >[color=green]
      >>popwin.docume nt.data.user=us er;[/color][/color]

      Hmmm. This is interesting. Here's what my code looks like now:

      function setValue(win,va l) {
      win.document.da ta.user = val;
      }

      function popUpPassword(u ser) {
      popwin = window.open('my pop.html', "external",
      "width=500,heig ht=500,resizabl e=no,scrollbars =no,status=yes, location=yes,to olbar=no,menuba r=no");

      setTimeout('set Value(popwin,us er)',1000);
      }

      However, when the timeout goes off, I get a javascript error saying
      that "user is not defined". It seems to be complaining about the start
      of the next function!

      It gets weirder. I copied the above code from the "Show Source"
      output. However, when I click on the link in the javascript error
      window, it shows this:

      <script Language="JavaS cript">
      <!-- Begin
      function popUpPassword(U RL,w,h) {
      window.open(url , "external", "width=" + w +",height=" + h +
      ",resizable=no, scrollbars=no,s tatus=no,locati on=no,toolbar=n o,menubar=no");
      }
      // End -->
      </script>

      That's just totally bizzare. I'm using Firefox. IE shows me a
      similar error, but it's nearly friendly enough to show me the code.

      -Greg G

      Comment

      • kaeli

        #4
        Re: Popup and set data?

        In article <KpydnYJ6TIpZ6t zfRVn-iA@ctc.net>, ggershSNACK@CAK Ectc.net
        enlightened us with...[color=blue]
        > setTimeout('set Value(popwin,us er)',1000);
        > }
        >
        > However, when the timeout goes off, I get a javascript error saying
        > that "user is not defined". It seems to be complaining about the start
        > of the next function![/color]

        Yeah, you can't do that.
        The variables are out of scope by the time the setTimeout runs. Make them
        global.
        [color=blue]
        >
        > It gets weirder. I copied the above code from the "Show Source"
        > output. However, when I click on the link in the javascript error
        > window, it shows this:[/color]

        What link?
        Could you be having a problem with caching?
        I often do with Firefox. I have to control+shift+r eload sometimes.

        I assume both pages are yours, correct?
        Put this function in mypop.html:

        <script type="text/javascript">
        function setUser(user)
        {
        document.data.u ser = user;
        }
        </script>

        Now change your popup script in the other page to:


        function popUpPassword(u ser)
        {
        var win = null;
        int count = 0;
        win = window.open('my pop.html', "external",
        "width=500,heig ht=
        500,resizable=n o,scrollbars=no ,status=yes,loc ation=yes,toolb ar=no,menubar=n o"
        );
        while (win == null)
        {
        /* give time to load, but don't let it be an endless loop. Change value
        to a higher number if the content is image heavy or takes a long time
        normally. Also, if popup was blocked, win will be null. */
        count ++;
        if (count == 5000) break;
        }
        if (win == null) return false; /* Just couldn't do it. Add error handling
        here if you want.*/

        win.setUser(use r);
        return true;
        }

        --
        --
        ~kaeli~
        Murphy's Law #2030: If at first you don't succeed, destroy
        all evidence that you tried.



        Comment

        • Greg G

          #5
          Re: Popup and set data?

          kaeli wrote:[color=blue]
          > In article <KpydnYJ6TIpZ6t zfRVn-iA@ctc.net>, ggershSNACK@CAK Ectc.net
          > enlightened us with...
          >[color=green]
          >> setTimeout('set Value(popwin,us er)',1000);
          >>}
          >>
          >> However, when the timeout goes off, I get a javascript error saying
          >>that "user is not defined". It seems to be complaining about the start
          >>of the next function![/color]
          >
          >
          > Yeah, you can't do that.
          > The variables are out of scope by the time the setTimeout runs. Make them
          > global.[/color]

          Ah. I see. That's....inter esting. But globalness might not help.
          There's a bunch of buttons on this screen. (Oh, and is there a way to
          make a form do nothing when a button is pressed? All of my buttons are
          type=button but they all act like submit, and I really want the
          individual button control to take over. That's not really a big deal, I
          just took out the form tag. It's ok on the source page...)
          [color=blue][color=green]
          >> It gets weirder. I copied the above code from the "Show Source"
          >>output. However, when I click on the link in the javascript error
          >>window, it shows this:[/color]
          >
          > What link?[/color]

          The link in the "javascript :" window that says there's an error.
          [color=blue]
          > Could you be having a problem with caching?[/color]

          I don't think so. In fact, I'm having a problem where the POSTDATA
          doesn't get refreshed when I reload the cgi.
          [color=blue]
          > I often do with Firefox. I have to control+shift+r eload sometimes.
          >
          > I assume both pages are yours, correct?
          > Put this function in mypop.html:
          >
          > <script type="text/javascript">
          > function setUser(user)
          > {
          > document.data.u ser = user;
          > }
          > </script>
          >
          > Now change your popup script in the other page to:
          >
          >
          > function popUpPassword(u ser)
          > {
          > var win = null;
          > int count = 0;[/color]

          I had to do this as var count = 0; Javascript: complained that
          "int" was a reserved identifier.

          [color=blue]
          > win = window.open('my pop.html', "external",
          > "width=500,heig ht=
          > 500,resizable=n o,scrollbars=no ,status=yes,loc ation=yes,toolb ar=no,menubar=n o"
          > );
          > while (win == null)
          > {
          > /* give time to load, but don't let it be an endless loop. Change value
          > to a higher number if the content is image heavy or takes a long time
          > normally. Also, if popup was blocked, win will be null. */
          > count ++;
          > if (count == 5000) break;
          > }
          > if (win == null) return false; /* Just couldn't do it. Add error handling
          > here if you want.*/
          >
          > win.setUser(use r);[/color]

          No go. I get a message in the javascript: window that "win.setUse r"
          is not a function. Nothing happens in the popup.
          [color=blue]
          > return true;
          > }
          >[/color]

          -Greg G

          Comment

          • kaeli

            #6
            Re: Popup and set data?

            In article <XP-dnbtHSc0aGtTfRV n-sQ@ctc.net>, ggershSNACK@CAK Ectc.net
            enlightened us with...[color=blue][color=green]
            > >
            > > Yeah, you can't do that.
            > > The variables are out of scope by the time the setTimeout runs. Make them
            > > global.[/color]
            >
            > Ah. I see. That's....inter esting. But globalness might not help.
            > There's a bunch of buttons on this screen. (Oh, and is there a way to
            > make a form do nothing when a button is pressed?[/color]

            Sure.
            If you know for *sure* all your users have javascript, don't give the form an
            action or method in the form tag or any buttons of type submit.
            In the onClick for each button, set the action, method, and do form.submit().
            Note that this may prevent firing of any onSubmit events, so don't count on
            one. Note that it also might not be very accessible to users with
            disabilities.
            [color=blue]
            > All of my buttons are
            > type=button but they all act like submit[/color]

            They shouldn't. How are you coding this form?
            The form tag is REQUIRED to submit to a server properly, I believe. Removing
            it would not be a good idea unless the buttons aren't meant to submit data to
            a server.
            [color=blue]
            >[color=green]
            > > Could you be having a problem with caching?[/color]
            >
            > I don't think so. In fact, I'm having a problem where the POSTDATA
            > doesn't get refreshed when I reload the cgi.[/color]

            That could indicate a problem with caching. Just not your browser.
            Are you using a proxy?
            [color=blue][color=green]
            > > var win = null;
            > > int count = 0;[/color]
            >
            > I had to do this as var count = 0; Javascript: complained that
            > "int" was a reserved identifier.[/color]

            Oops, my bad.
            Too much java and C lately. LOL

            Okay, I just tested this and it worked fine for me. Note:
            document.data.u ser.value (the value part was missing).

            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
            <html>
            <head>
            <title> test </title>
            <script type="text/javascript">
            function setUser(user)
            {
            document.data.u ser.value = user;
            }
            </script>

            </head>

            <body>
            <p>Test</p>
            <form name="data">
            <input type="text" name="user">
            </form>
            </body>
            </html>


            <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/html4/loose.dtd">
            <html>
            <head>
            <title> New Document </title>
            <script>
            function popUpPassword(u ser)
            {
            var win = null;
            var count = 0;
            win = window.open('te st.html', "test", "width=500,heig ht=
            500,resizable=n o,scrollbars=no ,status=yes,loc ation=yes,toolb ar=no,menubar=n o"
            );
            while (win == null)
            {
            /* give time to load, but don't let it be an endless loop. Change value
            to a higher number if the content is image heavy or takes a long time
            normally. Also, if popup was blocked, win will be null. */
            count ++;
            if (count == 5000) break;
            }
            if (win == null) return false; /* Just couldn't do it. Add error handling
            here if you want.*/

            win.setUser(use r);
            return true;
            }
            </script>
            </head>

            <body>
            <p>Click <a href="javascrip t:popUpPassword ('kaeli');">her e</a> to open popup
            and set user.</p>

            </body>
            </html>

            --
            --
            ~kaeli~
            Frisbeetarianis m (n.), The belief that, when you die, your
            soul goes up on the roof and gets stuck there.



            Comment

            • Greg G

              #7
              Re: Popup and set data?


              This is so damn frustrating. Here's what I've got.

              ----myform.html----
              <html>
              <head>
              <title>My Form</title>
              <script type='text/javascript'>
              function setValue(num) {
              document.data.p hone.value = num;
              }
              </script>
              </head>

              <body>
              <p>
              <form name="data">
              <input type="text" name="phone">
              </form>
              </body>
              </html>
              ----myform.html----

              at the top of my index.html

              <html>
              <head>
              <title>VLAN Lookup Index</title>
              <script type='text/javascript'>
              <!--
              function popEdit(phone) {
              var win = null;
              var count = 0;

              win = window.open('my form.html','foo ',
              'resizeable=no, width=100,heigh t=100');
              while (win == null)
              {
              count ++;
              if (count == 5000) break;
              }
              if (win == null) return false; /* Just couldn't do it. Add error
              handling here if you want.*/

              win.setValue(ph one);
              return true;
              }
              -->
              </script>
              </head>

              Calls to popEdit in Firefox give me

              Error: win.setValue is not a function
              Source File: http://ggershowitz3.progpl.ctc.net/static_ip/index.cgi
              Line: 18

              Calls to popEdit in Internet Explorer give me
              Line: 18
              Char: 4
              Error: Object doesn't support this property or method
              Code: 0

              I don't get it. It doesn't get a whole lot simpler than that, right?

              -Greg G

              Comment

              • kaeli

                #8
                Re: Popup and set data?

                In article <PpOdnbp5N66WxN DfRVn-jg@ctc.net>, ggershSNACK@CAK Ectc.net
                enlightened us with...[color=blue]
                >
                > This is so damn frustrating. Here's what I've got.[/color]

                Okay, how about you supply a URL and I see if your full script works for me?
                Let's make sure it isn't something about your browser configs or some other
                piece of script that is making an error or maybe it's the way you're sending
                the value for phone. Sometimes a missing semi-colon in one piece does really
                odd things to other pieces or errors come from the oddest places.

                Oh, and you're not doing something like having the two pages be on different
                domains, are you? 'Cuz you can't do that.

                --
                --
                ~kaeli~
                Reading while sunbathing makes you well red.



                Comment

                • kaeli

                  #9
                  Re: Popup and set data?

                  In article <PpOdnbp5N66WxN DfRVn-jg@ctc.net>, ggershSNACK@CAK Ectc.net
                  enlightened us with...[color=blue]
                  >
                  > This is so damn frustrating. Here's what I've got.
                  >
                  >
                  > at the top of my index.html[/color]

                  This appears to be coming from index.cgi, something I just noticed.
                  Did you actually view the source of the generated code from index.cgi? In the
                  browser with view source? Because sometimes you aren't getting what you think
                  you're getting.
                  [color=blue]
                  >
                  > Error: win.setValue is not a function
                  > Source File: http://ggershowitz3.progpl.ctc.net/static_ip/index.cgi[/color]

                  ^^^
                  index.cgi?
                  Yeah, post the source your browser is actually looking at (or a valid URL,
                  'cuz this one isn't coming up). I bet you're missing a quote in that perl
                  print statementor something. ;)


                  --
                  --
                  ~kaeli~
                  All I ask is the chance to prove that money cannot make me
                  happy.



                  Comment

                  • RobB

                    #10
                    Re: Popup and set data?

                    Greg G wrote:[color=blue]
                    > This is so damn frustrating. Here's what I've got.[/color]

                    (snip)

                    Junk it. That whole approach is bizarre, particularly that while loop.
                    JavaScript is largely event-driven: since the 'event' you're expecting
                    here is the opening of the pop-up window, you should be calling this
                    routine from the window.onload handler of that window - it *knows* when
                    it's ready:

                    window.onload = function()
                    {
                    var form, from, to;
                    if ((form = document.data)
                    && (to = form.user))
                    {
                    if (opener
                    && !opener.closed
                    && (form = opener.document .data)
                    && (from = form.user))
                    to.value = from.value;
                    }
                    }

                    This assumes you're writing from document.data.u ser in the opener
                    window to document.data.u ser in the pop-up.

                    Comment

                    • kaeli

                      #11
                      Re: Popup and set data?

                      In article <1112372891.057 583.30000@o13g2 000cwo.googlegr oups.com>, ferndoc9
                      @hotmail.com enlightened us with...[color=blue]
                      > Greg G wrote:[color=green]
                      > > This is so damn frustrating. Here's what I've got.[/color]
                      >
                      > (snip)
                      >
                      > Junk it. That whole approach is bizarre, particularly that while loop.[/color]

                      ....
                      [color=blue]
                      > This assumes you're writing from document.data.u ser in the opener
                      > window to document.data.u ser in the pop-up.[/color]

                      And doesn't work at all if you aren't.

                      The approach I posted works (well, for me anyway, YMMV, I guess) for any
                      window calling the code and does not rely on matching form fields or assume
                      anything at all about an opener, a frame sibling, or anything else. It can be
                      called by the opener, another window in a frameset, or its own child.

                      The while loop waits for load without trying to add an event. If you prefer
                      to add an event, feel free. ;)
                      I prefer the while loop since I can then handle the lack of a load at all
                      (404, server error, etc). Plus I don't have to putz around with browser
                      compatibility with events.

                      As always, script leaves a lot of room for creativity. Use what works for
                      you.

                      --
                      --
                      ~kaeli~
                      If a turtle doesn't have a shell, is he homeless or naked?



                      Comment

                      • RobB

                        #12
                        Re: Popup and set data?

                        kaeli wrote:[color=blue]
                        > In article <1112372891.057 583.30000@o13g2 000cwo.googlegr oups.com>,[/color]
                        ferndoc9[color=blue]
                        > @hotmail.com enlightened us with...[color=green]
                        > > Greg G wrote:[color=darkred]
                        > > > This is so damn frustrating. Here's what I've got.[/color]
                        > >
                        > > (snip)
                        > >
                        > > Junk it. That whole approach is bizarre, particularly that while[/color][/color]
                        loop.[color=blue]
                        >
                        > ...
                        >[color=green]
                        > > This assumes you're writing from document.data.u ser in the opener
                        > > window to document.data.u ser in the pop-up.[/color]
                        >
                        > And doesn't work at all if you aren't.[/color]

                        Great point (?) Could be modified in 15 sec. to transfer a simple
                        variable.
                        [color=blue]
                        > The approach I posted works (well, for me anyway, YMMV, I guess) for[/color]
                        any[color=blue]
                        > window calling the code and does not rely on matching form fields or[/color]
                        assume[color=blue]
                        > anything at all about an opener, a frame sibling, or anything else.[/color]
                        It can be[color=blue]
                        > called by the opener, another window in a frameset, or its own child.
                        >
                        > The while loop waits for load without trying to add an event. If you[/color]
                        prefer[color=blue]
                        > to add an event, feel free. ;)
                        > I prefer the while loop since I can then handle the lack of a load at[/color]
                        all[color=blue]
                        > (404, server error, etc). Plus I don't have to putz around with[/color]
                        browser[color=blue]
                        > compatibility with events.[/color]

                        No idea what relevance any of that laundry list has to
                        anything...what 's the point of using a form of polling here? Call the
                        routine from the window being created (or pass the data in a
                        querystring to it). Why script this from the opener when the execution
                        context of the pop-up is completely capable of fetching its own data?

                        ----myform.html----

                        <html>
                        <head>
                        <title>My Form</title>
                        <script type="text/javascript">

                        window.onload = function()
                        {
                        if (opener
                        && !opener.closed
                        && opener.phonenum )
                        document.data.p hone.value = opener.phonenum ;
                        }

                        </script>
                        </head>
                        <body>
                        <form name="data">
                        <input type="text" name="phone">
                        </form>
                        </body>
                        </html>

                        ----myform.html----

                        ----index.html----

                        <html>
                        <head>
                        <title>VLAN Lookup Index</title>
                        <script type="text/javascript">

                        var win = null;
                        var phonenum = '';

                        function popEdit(phone)
                        {
                        phonenum = phone;
                        win = window.open(
                        'myform.html',
                        'win­',
                        'width=100,heig h­t=100'
                        );
                        }

                        </script>
                        </head>
                        <body>
                        <form>
                        <input
                        type="button"
                        value="next"
                        onclick="popEdi t('332-666-8739')">
                        </form>
                        </body>
                        </html>

                        ----index.html----

                        Comment

                        • RobB

                          #13
                          Re: Popup and set data?

                          kaeli wrote:[color=blue]
                          > In article <1112372891.057 583.30000@o13g2 000cwo.googlegr oups.com>,[/color]
                          ferndoc9[color=blue]
                          > @hotmail.com enlightened us with...[color=green]
                          > > Greg G wrote:[color=darkred]
                          > > > This is so damn frustrating. Here's what I've got.[/color]
                          > >
                          > > (snip)
                          > >
                          > > Junk it. That whole approach is bizarre, particularly that while[/color][/color]
                          loop.[color=blue]
                          >
                          > ...
                          >[color=green]
                          > > This assumes you're writing from document.data.u ser in the opener
                          > > window to document.data.u ser in the pop-up.[/color]
                          >
                          > And doesn't work at all if you aren't.[/color]

                          Great point (?) Could be modified in 15 sec. to transfer a simple
                          variable.
                          [color=blue]
                          > The approach I posted works (well, for me anyway, YMMV, I guess) for[/color]
                          any[color=blue]
                          > window calling the code and does not rely on matching form fields or[/color]
                          assume[color=blue]
                          > anything at all about an opener, a frame sibling, or anything else.[/color]
                          It can be[color=blue]
                          > called by the opener, another window in a frameset, or its own child.
                          >
                          > The while loop waits for load without trying to add an event. If you[/color]
                          prefer[color=blue]
                          > to add an event, feel free. ;)
                          > I prefer the while loop since I can then handle the lack of a load at[/color]
                          all[color=blue]
                          > (404, server error, etc). Plus I don't have to putz around with[/color]
                          browser[color=blue]
                          > compatibility with events.[/color]

                          No idea what relevance any of that laundry list has to
                          anything...what 's the point of using a form of polling here? Call the
                          routine from the window being created (or pass the data in a
                          querystring to it). Why script this from the opener when the execution
                          context of the pop-up is completely capable of fetching its own data?

                          ----myform.html----

                          <html>
                          <head>
                          <title>My Form</title>
                          <script type="text/javascript">

                          window.onload = function()
                          {
                          if (opener
                          && !opener.closed
                          && opener.phonenum )
                          document.data.p hone.value = opener.phonenum ;
                          }

                          </script>
                          </head>
                          <body>
                          <form name="data">
                          <input type="text" name="phone">
                          </form>
                          </body>
                          </html>

                          ----myform.html----

                          ----index.html----

                          <html>
                          <head>
                          <title>VLAN Lookup Index</title>
                          <script type="text/javascript">

                          var win = null;
                          var phonenum = '';

                          function popEdit(phone)
                          {
                          phonenum = phone;
                          win = window.open(
                          'myform.html',
                          'win­',
                          'width=100,heig h­t=100'
                          );
                          }

                          </script>
                          </head>
                          <body>
                          <form>
                          <input
                          type="button"
                          value="next"
                          onclick="popEdi t('332-666-8739')">
                          </form>
                          </body>
                          </html>

                          ----index.html----

                          Comment

                          • kaeli

                            #14
                            Re: Popup and set data?

                            In article <1112383925.991 864.310910@g14g 2000cwa.googleg roups.com>, ferndoc9
                            @hotmail.com enlightened us with...[color=blue][color=green]
                            > >[color=darkred]
                            > > > This assumes you're writing from document.data.u ser in the opener
                            > > > window to document.data.u ser in the pop-up.[/color]
                            > >
                            > > And doesn't work at all if you aren't.[/color]
                            >
                            > Great point (?) Could be modified in 15 sec. to transfer a simple
                            > variable.[/color]

                            So if I have 3 documents calling it that have different fields?
                            I'm supposed to modify it for every page that calls it?
                            I think not.
                            (note: my stuff isn't static html; it's JSP, and field names change according
                            to bean properties)

                            The simple principle of data hiding and encapsulation can be applied to web
                            pages, too.
                            I don't see the need to create dependencies where they are not needed.
                            YMMV, which it obviously does.

                            [color=blue]
                            > what's the point of using a form of polling here? Call the
                            > routine from the window being created (or pass the data in a
                            > querystring to it).[/color]

                            You want to create a need to know the parameters right when the window is
                            opened, go for it. You want to make the child know what fields are in the
                            parent, go for it. I do not.
                            [color=blue]
                            > Why script this from the opener when the execution
                            > context of the pop-up is completely capable of fetching its own data?[/color]

                            The window may have 8 or 18 fields that can be set or retrieved at any time
                            by any document in the same domain that opened it or have any relation to it.
                            Maybe I want to set 3 fields from one document, but 3 other fields from
                            another. Simple setters and getters for fields allow this with no problems.
                            And if the other pages change their form fields, I don't have to change the
                            popup document.

                            If you don't see a need for it, don't use it.
                            There are always many ways of doing things. Do what works for you.

                            --
                            --
                            ~kaeli~
                            Frisbeetarianis m (n.), The belief that, when you die, your
                            soul goes up on the roof and gets stuck there.



                            Comment

                            • Greg G

                              #15
                              Re: Popup and set data?

                              kaeli wrote:[color=blue]
                              > In article <PpOdnbp5N66WxN DfRVn-jg@ctc.net>, ggershSNACK@CAK Ectc.net
                              > enlightened us with...
                              >[color=green]
                              >>This is so damn frustrating. Here's what I've got.
                              >>
                              >>
                              >>at the top of my index.html[/color]
                              >
                              >
                              > This appears to be coming from index.cgi, something I just noticed.
                              > Did you actually view the source of the generated code from index.cgi? In the
                              > browser with view source? Because sometimes you aren't getting what you think
                              > you're getting.
                              >
                              >[color=green]
                              >>Error: win.setValue is not a function
                              >>Source File: http://ggershowitz3.progpl.ctc.net/static_ip/index.cgi[/color]
                              >
                              >
                              > ^^^
                              > index.cgi?
                              > Yeah, post the source your browser is actually looking at (or a valid URL,
                              > 'cuz this one isn't coming up). I bet you're missing a quote in that perl
                              > print statementor something. ;)
                              >
                              >[/color]

                              I was completely unable to get the setValue function to be called from
                              the opener. It never ran, and I always got the error message saying
                              that win.setValue is not a function. If I were missing a quote, it
                              wouldn't get to the point of trying to call the function.

                              Here's the myform.html that's the target of this win.open:

                              <html>
                              <head>
                              <title>My Form</title>
                              <script type='text/javascript'>
                              function setValue(num) {
                              document.data.p hone.value = num;
                              }
                              </script>
                              </head>

                              <body>
                              <p>
                              <form name="data">
                              <input type="text" name="phone">
                              </form>
                              </body>
                              </html>


                              I've got a cgi which is generating the HTML on the fly, since I'm
                              reading a bunch of data out of a back-end database.

                              I'm still interesting in seeing this work. Is there not a utility to do
                              a sanity check on javascript? It seems crazy that there's no way to
                              debug what I've written.

                              Also, I was able to get the data across using a simplification of RobB's
                              technique. Since this is a single-purpose popup and is only going to be
                              called from one specific page, I did this, and it worked:

                              window.onload = function()
                              {
                              var form = document.inform ation;

                              form.phone.valu e = opener.phone_va lue;
                              }

                              where phone_value is a global variable in the opening window.

                              -Greg G

                              Comment

                              Working...