Assign a value to a hidden field from javascript
-
function SetValue() { var width = screen.width; var height = screen.height; document.getElementById('hdnVal').value = width+'*'+height; } after i call the function window.onload = SetValue(); <script></x-turndown>
-
function SetValue() { var width = screen.width; var height = screen.height; document.getElementById('hdnVal').value = width+'*'+height; } after i call the function window.onload = SetValue(); <script></x-turndown>
-
Hi, How to assign a value to a hidden field from javascript in page load. eg: I when a page load the screen resolution is taken from javascript and assign to a hidden field, and i need to do some work using the hiddenfield in code behind When i try the value is assign in javascript but in code behind it shown blank in hiddenfield Thankyou YPKI
-
function SetValue() { var width = screen.width; var height = screen.height; document.getElementById('hdnVal').value = width+'*'+height; } after i call the function window.onload = SetValue(); <script></x-turndown>
-
Hi, How to assign a value to a hidden field from javascript in page load. eg: I when a page load the screen resolution is taken from javascript and assign to a hidden field, and i need to do some work using the hiddenfield in code behind When i try the value is assign in javascript but in code behind it shown blank in hiddenfield Thankyou YPKI
I suspect your issue is that you use the server side id of the control. You need to use the ClientID property of the control to work out the id you need to pass to the client to search for the control. You can also use Firebug in Firefox to step through your js and see what is happening.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
I suspect your issue is that you use the server side id of the control. You need to use the ClientID property of the control to work out the id you need to pass to the client to search for the control. You can also use Firebug in Firefox to step through your js and see what is happening.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
When i give in alert, the value is displayed in alert box, but it is empty in code behind.
-
When i give in alert, the value is displayed in alert box, but it is empty in code behind.
Well, your code sucks because it called getElementById and does not check that something was returned. Have you tried what I suggested ? Are you SURE you're using the right client side id ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
Well, your code sucks because it called getElementById and does not check that something was returned. Have you tried what I suggested ? Are you SURE you're using the right client side id ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
contols i tried, and i try getElementById and getElementsByName also both giving right result in alert box, but blank in code behind. A javascrprt error:'Not Implemented' also
-
contols i tried, and i try getElementById and getElementsByName also both giving right result in alert box, but blank in code behind. A javascrprt error:'Not Implemented' also
ypki wrote:
A javascrprt error:'Not Implemented' also
So there is your issue. Again, you need to pass the client id through in your script. Just like I told you in my first reply
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
-
ypki wrote:
A javascrprt error:'Not Implemented' also
So there is your issue. Again, you need to pass the client id through in your script. Just like I told you in my first reply
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
how?
-
Hi, How to assign a value to a hidden field from javascript in page load. eg: I when a page load the screen resolution is taken from javascript and assign to a hidden field, and i need to do some work using the hiddenfield in code behind When i try the value is assign in javascript but in code behind it shown blank in hiddenfield Thankyou YPKI
function SetValue() { var width = screen.width; var height = screen.height; document.getElementById('<%= hdnVal.ClientID %>').value = width+'*'+height; } use this function to set value in hiddenfield through javascript.