javascripting form values

M

Mike Mueller

How can something seemingly so simple make me pull out so
much hair.....

I am using javascript to get browser info and screen
resolution. This information will be tacked into a form
using hidden fields. I am getting nothing for the values of
the hidden fields. All else is saving fine to the database.

script portions:

<form method="POST" action="--WEBBOT-SELF--" name="Info"
onSubmit="">
--snip--
<input type="hidden" name="Browser" value="">
<input type="hidden" name="FullBrower" value="">
<input type="hidden" name="Resolution" value="">
</form>
<script>
form.info.Browser.value=navigator.appName + " " +
parseInt(navigator.appVersion);
form.info.FullBrowser.value=window.navigator.userAgent;
form.info.Resolution.value=ScrnSz;
</script>
 
J

Jon Spivey

Hi Mike,

I'd grab the browser/ua information server side and just get the res client
side
<form....
<input type="hidden" name="Browser"
value="<%=request.servervariables("http_user_agent")%>">
<input type="hidden" name="Resolution" value="">
</form>
<script type="text.javascript">
document.forms[0].Resolution.value = screen.width + 'x' + screen.height;
</script>

Having said that a post came up earlier today in the client group about the
usefullness of screen resolution versus window size - if you'd rather get
window size look at the the thread next door
 
K

Kevin Spencer

You must be overlooking or not displaying JavaScript errors. "form.info"
would cause one. Instead, try referring to the form as "document.forms[0]".
Example:

document.forms[0].Browser.value=navigator.appName + " " +
parseInt(navigator.appVersion);

Also, what exactly is "ScrnSz" supposed to be? You can't just make up terms
and expect them to work somehow. In the context of your code, it looks like
a variable. But it's never declared, and you never assign a value to it. Try
using screen.height and screen.width instead.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
M

Mike Mueller

Once agaoin I need to say thank you.

Part of my problem was mizspeling. I am now functioning
with window.document.formfield.value.

I knew I could pull the referer server side, but that would
cross out of my realm into the next bank of cubicles who are
just going to import this into interdev

Screen resolution is desired for this site as due to the
nature of high quality images being displayed.

Mike




Jon Spivey wrote:
: Hi Mike,
:
: I'd grab the browser/ua information server side and just
: get the res client side
: <form....
: <input type="hidden" name="Browser"
: value="<%=request.servervariables("http_user_agent")%>">
: <input type="hidden" name="Resolution" value="">
: </form>
: <script type="text.javascript">
: document.forms[0].Resolution.value = screen.width + 'x'
: + screen.height; </script>
:
: Having said that a post came up earlier today in the
: client group about the usefullness of screen resolution
: versus window size - if you'd rather get window size
: look at the the thread next door
:
:
: message :: How can something seemingly so simple make me pull out so
:: much hair.....
::
:: I am using javascript to get browser info and screen
:: resolution. This information will be tacked into a form
:: using hidden fields. I am getting nothing for the
:: values of the hidden fields. All else is saving fine to
:: the database.
::
:: script portions:
::
:: <form method="POST" action="--WEBBOT-SELF--" name="Info"
:: onSubmit="">
:: --snip--
:: <input type="hidden" name="Browser" value="">
:: <input type="hidden" name="FullBrower" value="">
:: <input type="hidden" name="Resolution" value="">
:: </form>
:: <script>
:: form.info.Browser.value=navigator.appName + " " +
:: parseInt(navigator.appVersion);
:: form.info.FullBrowser.value=window.navigator.userAgent;
:: form.info.Resolution.value=ScrnSz;
:: </script>
 
M

Mike Mueller

Thank you Kevin

besides what I stated to Jon, scrnsz was defined higher up
in the code based on those variables you named

mike


Kevin Spencer wrote:
: You must be overlooking or not displaying JavaScript
: errors. "form.info" would cause one. Instead, try
: referring to the form as "document.forms[0]". Example:
:
: document.forms[0].Browser.value=navigator.appName + " " +
: parseInt(navigator.appVersion);
:
: Also, what exactly is "ScrnSz" supposed to be? You can't
: just make up terms and expect them to work somehow. In
: the context of your code, it looks like a variable. But
: it's never declared, and you never assign a value to it.
: Try using screen.height and screen.width instead.
:
:
: message :: How can something seemingly so simple make me pull out so
:: much hair.....
::
:: I am using javascript to get browser info and screen
:: resolution. This information will be tacked into a form
:: using hidden fields. I am getting nothing for the
:: values of the hidden fields. All else is saving fine to
:: the database.
::
:: script portions:
::
:: <form method="POST" action="--WEBBOT-SELF--" name="Info"
:: onSubmit="">
:: --snip--
:: <input type="hidden" name="Browser" value="">
:: <input type="hidden" name="FullBrower" value="">
:: <input type="hidden" name="Resolution" value="">
:: </form>
:: <script>
:: form.info.Browser.value=navigator.appName + " " +
:: parseInt(navigator.appVersion);
:: form.info.FullBrowser.value=window.navigator.userAgent;
:: form.info.Resolution.value=ScrnSz;
:: </script>
 

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