Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #11769 > unrolled thread

document.write within a form

Started bycerr <ron.eggler@gmail.com>
First post2012-02-14 22:29 -0800
Last post2012-02-15 10:52 -0800
Articles 3 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  document.write within a form cerr <ron.eggler@gmail.com> - 2012-02-14 22:29 -0800
    Re: document.write within a form "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-02-15 09:18 +0200
      Re: document.write within a form cerr <ron.eggler@gmail.com> - 2012-02-15 10:52 -0800

#11769 — document.write within a form

Fromcerr <ron.eggler@gmail.com>
Date2012-02-14 22:29 -0800
Subjectdocument.write within a form
Message-ID<8d6567e4-a028-4c9f-83e1-5063099fe00e@og8g2000pbb.googlegroups.com>
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

[toc] | [next] | [standalone]


#11770

From"Jukka K. Korpela" <jkorpela@cs.tut.fi>
Date2012-02-15 09:18 +0200
Message-ID<jhfm7i$14s$1@dont-email.me>
In reply to#11769
2012-02-15 8:29, cerr wrote:

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

-- 
Yucca, http://www.cs.tut.fi/~jkorpela/

[toc] | [prev] | [next] | [standalone]


#11795

Fromcerr <ron.eggler@gmail.com>
Date2012-02-15 10:52 -0800
Message-ID<37a48e45-65b9-497e-9f18-e1f6affa4696@v6g2000pba.googlegroups.com>
In reply to#11770
On Feb 14, 11:18 pm, "Jukka K. Korpela" <jkorp...@cs.tut.fi> wrote:
> 2012-02-15 8:29,cerrwrote:
> > 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 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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web