Abdul Abdul - 1 year ago 78
Javascript Question

Set Default Value for hidden field

I have a hidden field where i save a value when button is clicked. But on page load there is no value assigned to it. I need to know how to set default value of hidden field.

I am saving a string in hidden field when button is clicked and then access it in a JS function. But on page load the JS function return Undefined value error as the value of hidden field is not set on page load.

function Confirm() {
var nom = document.getElementById('hdNomValue').Value;
if (nom != "")
// logic here

ddb ddb
Answer Source

try to use this

if (nom !== "" && nom !== undefined) 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download