Javascript problem with form submission on Seamonkey

Discussion in 'HTML' started by Daniel Rudy, Apr 28, 2008.

  1. Daniel Rudy

    Daniel Rudy Guest

    Consider the following code:

    <?php

    if (isset($_POST['width']) && isset($_POST['height']))
    {
    // output the geometry variables
    print "Window width is: ". $_POST['width'] ."<br>\n";
    print "Window height is: ". $_POST['height'] ."<br>\n";
    }
    else
    {
    print <<<HTMLBLOCK
    <form name="screensize" method="POST" action="$_SERVER[PHP_SELF]">
    <input type="hidden" name="width" value="">
    <input type="hidden" name="height" value="">
    </form>

    <script language="javascript">
    var myform = document.screensize;
    myform.width.value = screen.width;
    myform.height.value = screen.height;
    myform.submit();
    </script>

    HTMLBLOCK;
    }

    ?>

    This code renders as the following in a web browser:

    <form name="screensize" method="POST" action="/test/test.php">
    <input type="hidden" name="width" value="">
    <input type="hidden" name="height" value="">
    </form>

    <script language="javascript">
    var myform = document.screensize;
    myform.width.value = screen.width; <-- Line 8
    myform.height.value = screen.height;
    myform.submit();
    </script>


    Here's the problem. In IE7, this works just fine. But in Seamonkey
    1.1.8, it fails (blank page). The error console gives the following
    error: myform has ho properties (line 8). I haven't tried it in other
    browsers. I have exhausted my reference documentation, and I couldn't
    find an answer on Google either. Everything I found says this should
    work, but it's not. Any ideas?

    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m
     
    Daniel Rudy, Apr 28, 2008
    #1
    1. Advertising

  2. Daniel Rudy wrote:
    > Consider the following code:
    >
    > <?php
    >
    > if (isset($_POST['width']) && isset($_POST['height']))
    > {
    > // output the geometry variables
    > print "Window width is: ". $_POST['width'] ."<br>\n";
    > print "Window height is: ". $_POST['height'] ."<br>\n";
    > }
    > else
    > {
    > print <<<HTMLBLOCK
    > <form name="screensize" method="POST" action="$_SERVER[PHP_SELF]">
    > <input type="hidden" name="width" value="">
    > <input type="hidden" name="height" value="">
    > </form>
    >
    > <script language="javascript">
    > var myform = document.screensize;
    > myform.width.value = screen.width;
    > myform.height.value = screen.height;
    > myform.submit();
    > </script>
    >
    > HTMLBLOCK;
    > }
    >
    > ?>
    >
    > This code renders as the following in a web browser:
    >
    > <form name="screensize" method="POST" action="/test/test.php">
    > <input type="hidden" name="width" value="">
    > <input type="hidden" name="height" value="">
    > </form>
    >
    > <script language="javascript">
    > var myform = document.screensize;
    > myform.width.value = screen.width; <-- Line 8
    > myform.height.value = screen.height;
    > myform.submit();
    > </script>
    >
    >
    > Here's the problem. In IE7, this works just fine. But in Seamonkey
    > 1.1.8, it fails (blank page). The error console gives the following
    > error: myform has ho properties (line 8). I haven't tried it in other
    > browsers. I have exhausted my reference documentation, and I couldn't
    > find an answer on Google either. Everything I found says this should
    > work, but it's not. Any ideas?
    >


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    <meta http-equiv="content-language" content="en-us">
    <title>What document.screensize?</title>

    <script type="text/javascript">
    function getObj(){
    var doc = document;
    var dump = doc.getElementById('dump');
    for (var obj in doc) {
    var clone=dump.cloneNode(true);
    clone.firstChild.nodeValue=obj;
    doc.body.appendChild(clone);
    }
    }
    </script>

    </head>
    <body onload="getObj()">
    <h1>What document.screensize?</h1>
    <div id="dump">Objects in document collection:</div>
    </body>
    </html>


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Apr 28, 2008
    #2
    1. Advertising

  3. Daniel Rudy

    Daniel Rudy Guest

    At about the time of 4/28/2008 8:58 AM, Jonathan N. Little stated the
    following:
    > Daniel Rudy wrote:
    >> Consider the following code:
    >>
    >> <?php
    >>
    >> if (isset($_POST['width']) && isset($_POST['height']))
    >> {
    >> // output the geometry variables
    >> print "Window width is: ". $_POST['width'] ."<br>\n";
    >> print "Window height is: ". $_POST['height'] ."<br>\n";
    >> }
    >> else
    >> {
    >> print <<<HTMLBLOCK
    >> <form name="screensize" method="POST" action="$_SERVER[PHP_SELF]">
    >> <input type="hidden" name="width" value="">
    >> <input type="hidden" name="height" value="">
    >> </form>
    >>
    >> <script language="javascript">
    >> var myform = document.screensize;
    >> myform.width.value = screen.width;
    >> myform.height.value = screen.height;
    >> myform.submit();
    >> </script>
    >>
    >> HTMLBLOCK;
    >> }
    >>
    >> ?>
    >>
    >> This code renders as the following in a web browser:
    >>
    >> <form name="screensize" method="POST" action="/test/test.php">
    >> <input type="hidden" name="width" value="">
    >> <input type="hidden" name="height" value="">
    >> </form>
    >>
    >> <script language="javascript">
    >> var myform = document.screensize;
    >> myform.width.value = screen.width; <-- Line 8
    >> myform.height.value = screen.height;
    >> myform.submit();
    >> </script>
    >>
    >>
    >> Here's the problem. In IE7, this works just fine. But in Seamonkey
    >> 1.1.8, it fails (blank page). The error console gives the following
    >> error: myform has ho properties (line 8). I haven't tried it in other
    >> browsers. I have exhausted my reference documentation, and I couldn't
    >> find an answer on Google either. Everything I found says this should
    >> work, but it's not. Any ideas?
    >>

    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd">
    > <html>
    > <head>
    > <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
    > <meta http-equiv="content-language" content="en-us">
    > <title>What document.screensize?</title>
    >
    > <script type="text/javascript">
    > function getObj(){
    > var doc = document;
    > var dump = doc.getElementById('dump');
    > for (var obj in doc) {
    > var clone=dump.cloneNode(true);
    > clone.firstChild.nodeValue=obj;
    > doc.body.appendChild(clone);
    > }
    > }
    > </script>
    >
    > </head>
    > <body onload="getObj()">
    > <h1>What document.screensize?</h1>
    > <div id="dump">Objects in document collection:</div>
    > </body>
    > </html>
    >
    >


    That actually works in both. I did yet another modification and I got
    it to work. So now I can get JavaScript variables to PHP using the POST
    method instead of the GET method that I have found all over the web.
    Here's the resulting code:


    <?php

    if (isset($_POST['width']) && isset($_POST['height']))
    {
    $width = $_POST['width'];
    $height = $_POST['height'];
    print <<<HTMLBLOCK
    <html>
    <head>
    <title>Javascript Variable to PHP Variable Test</title>
    </head>
    <body>
    Window Width: $width<br>
    Window Height: $height<br>
    </body>
    </html>

    HTMLBLOCK;
    }
    else
    {
    print <<<HTMLBLOCK
    <html>
    <head>
    <title>Javascript Variable to PHP Variable Test</title>
    <script language="javascript">
    function submitScreen()
    {
    form = document.getElementById("formSCR");
    form.width.value = screen.width;
    form.height.value = screen.height;
    form.submit();
    }
    </script>
    </head>
    <body onload="submitScreen()">
    <form id="formSCR" method="POST" action="$_SERVER[PHP_SELF]">
    <input type="hidden" name="width" value="" id="width">
    <input type="hidden" name="height" value="" id="height">
    </form>
    </body>
    </html>

    HTMLBLOCK;
    }

    ?>

    The other issue that I found was in the getElementById function.
    Javascript is alot like C, and so is PHP for that matter, but being case
    sensitive is a factor. I kept wondering why getElementByID would never
    work (It would say that it wasn't a function, which is correct).

    --
    Daniel Rudy

    Email address has been base64 encoded to reduce spam
    Decode email address using b64decode or uudecode -m
     
    Daniel Rudy, Apr 28, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. 1001 Webs

    Kompozer Vs SeaMonkey

    1001 Webs, Dec 6, 2007, in forum: HTML
    Replies:
    16
    Views:
    21,036
    andrew
    Jan 2, 2008
  2. Candoer

    Problem In SeaMonkey

    Candoer, May 8, 2008, in forum: HTML
    Replies:
    8
    Views:
    527
    Raymond SCHMIT
    May 9, 2008
  3. robert
    Replies:
    2
    Views:
    315
    robert
    Apr 6, 2009
  4. Mirjam_K.

    Login web control vs. Seamonkey

    Mirjam_K., Jul 12, 2010, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    684
    Mirjam_K.
    Jul 12, 2010
  5. cwdjrxyz

    SeaMonkey Browser Media Problem

    cwdjrxyz, Oct 6, 2006, in forum: Javascript
    Replies:
    0
    Views:
    142
    cwdjrxyz
    Oct 6, 2006
Loading...

Share This Page