This topic is locked

Hide/Show DIV based on Form Field

5/1/2017 12:07:25 PM
ASPRunner.NET General questions
S
swiersman author

All,
I am trying to hide a div on the View if a form fields value is "".
I tried using the following in the View page/JavaScript OnLoad event:
if (document.getElementById("view1_txtDeployCPType00").value == "")

{

document.getElementById("Initial").style.display = "none";
else

document.getElementById("Initial").style.display ="block";

}

  1. "view1_txtDeployCPType00" is the span id that is present when rendered. The form field is txtDeployCPType00.
  2. "Initial" is the DIV I am wishing to manipulate.
    Anyone have any suggestions what I am doing wrong?
    Many thanks,
    Scott

admin 5/1/2017

You making it unnecessary complicated. Instead of plain Javascript use Javascript API to read the value of the field.

https://xlinesoft.com/phprunner/docs/ctrl_getvalue.htm