post submit I want to javascript/client side read user input
var h = document.getElementById("myTEXTbox").value;
but the textbox only exists depending earlier user choices. is the an if object exists in javascript?
post submit I want to javascript/client side read user input
var h = document.getElementById("myTEXTbox").value;
but the textbox only exists depending earlier user choices. is the an if object exists in javascript?
check the return of getEelementById, if an element doesnt exist it will return null, and since it is a falsey value you can use it in a if statement.
var element = document.getElementById("myTEXTbox");
var h = element ? element.value : "";
So if element is not null, h will be set to element.value otherwise it will be set to an empty string
If the object exists then it is an object, if not, it will return undefined!
So you can test it like this:
var element = document.getElementById("myTEXTbox"),
h = (element)? element.value : '';
Basically, you are using this logic: If the element does exist "(element)" or alternatively (el!=undefined) then read the value, if not set the value of 'h' to '' (empty). This could be null or another value.