document.write within a form


C

cerr

Hi,

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" +
screen.availWidth);
dodcument.write("<input type=\"hidden\" name=\"height\" value=
\""+screen.availHeight+"\"/>");
dodcument.write("<input type=\"hidden\" name=\"width\" value=
\""+screen.availWidth+"\"/>");
</script>
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!
Ron
 
Ad

Advertisements

J

Jukka K. Korpela

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" +
screen.availWidth);
dodcument.write("<input type=\"hidden\" name=\"height\" value=
\""+screen.availHeight+"\"/>");
dodcument.write("<input type=\"hidden\" name=\"width\" value=
\""+screen.availWidth+"\"/>");
</script>
within the form but that doesn't seem to work, why not I'm wondering,

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).
 
Ad

Advertisements

C

cerr

2012-02-15 8:29,cerrwrote:

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 usedocument.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).
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?

Thanks,
Ron
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top