How to pass a value from an HTML hidden input to a JavaScript function?

S

Steve Kershaw

Hi,

I need to pass a value from a hidden input:
<input id="hiddentxtWidth" type="hidden" value="1065" />
to a JavaScript function.

I've tried the following:
<script type="text/javascript" >
window.resizeTo(<%= hiddentxtWidth.value %>, <%=
hiddentxtHeight.value %>);
</script>

But I get a "The name 'hiddertxtWidth' does not exist in the current
context" error.

I would very much like to store the page width and height in the
Web.Config file and pass it to the JavaScript function but I don't
know how to do that.

Any suggestions?
 
J

John Kotuby

Just type getElementById in google search and you'll see a bunch of
javascript links.

I don't know about using the web.config for holding window size information
but you can set session variables in the global.asax.
Then just grab session("elemW") if that's what you called it.
The syntax might not be exactly correct for grabbing the session variable,
but the concept is right.
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top