document.write within a form

Discussion in 'Javascript' started by cerr, Feb 15, 2012.

  1. cerr

    cerr Guest


    I would like to passalong two parameters as hidden fields within a
    form thus I did following:
    <script type="text/javascript">
    alert("screensize: "+screen.availHeight + "x" +
    dodcument.write("<input type=\"hidden\" name=\"height\" value=
    dodcument.write("<input type=\"hidden\" name=\"width\" value=
    within the form but that doesn't seem to work, why not I'm wondering,
    any hints or suggestion?
    Help would be appreciated!

    Thank you very much!
    cerr, Feb 15, 2012
    1. Advertisements

  2. Well, you didn't lint your code, did you? Which object might "dodcument" be?

    But the main point is that you shouldn't try to use document.write() for
    such purposes. Instead, add elements to the document tree in a
    structured manner. If you don't know how to do that, you shouldn't be
    messing around with document modifications before you've read a
    JavaScript tutorial.

    Or maybe the main point is really that you are trying to do the wrong
    thing, getting screen size and passing the information to a server.
    Unless you are trying to collect statistics, it's difficult to see what
    useful purpose it might serve (and not so difficult to guess what wrong
    ideas one might try to implement that way).
    Jukka K. Korpela, Feb 15, 2012
    1. Advertisements

  3. cerr

    cerr Guest

    Hi Jukka,

    Thanks for getting back - Wel I ultimately would like to adjust the
    size of a google map depending on the screensize cause the way i have
    it right now, it looks decent ona desktop screen but doesn't looks so
    good on my tablet e.g.... I thought I could pass the measures around
    to my script in the next page that prints out the html conmtaining the
    Google map and just adjust the image size appropriately... any better
    methods of doing that?

    cerr, Feb 15, 2012
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.