<script src="http://code.jquery.com/jquery-1.9.1.js"></script> css//the js file.. var person1; function getdata() { person1=prompt("Please enter your data 1","Sample 1",max="5"); } function displayResult() { var table1=document.getElementById("table1"); table1.innerHTML=person1; if(person1.value!="") { $("#table1").css({"border-color": "#000000", "border-width":"1px", "border-style":"solid", "visibility" : "visible", //"position" :"fixed", //"resize":"both", "overflow":"auto", "width":"60px", //"maxlength":"10", "height": "80px", "top": top1"30px", "left" : left1"80px"}); } else { alert("hello"); ("#table1").css({"border-color": "#000000", "border-width":"0px", "border-style":"solid", "visibility" : 'hidden', //"position" :"fixed", "resize":"both", "overflow":"auto", "width" :"60px", "height" : "80px", "top": "30px", "left" : "80px"}); } } <script src="http://code.jquery.com/jquery-1.9.1.js"></script> css//the js file.. var person1; function getdata() { person1=prompt("Please enter your data 1","Sample 1",max="5"); } function displayResult() { var table1=document.getElementById("table1"); table1.innerHTML=person1; if(person1.value!="") { $("#table1").css({"border-color": "#000000", "border-width":"1px", "border-style":"solid", "visibility" : "visible", //"position" :"fixed", //"resize":"both", "overflow":"auto", "width":"60px", //"maxlength":"10", "height": "80px", "top": top1, "left" : left1}); } else { alert("hello"); ("#table1").css({"border-color": "#000000", "border-width":"0px", "border-style":"solid", "visibility" : 'hidden', //"position" :"fixed", "resize":"both", "overflow":"auto", "width" :"60px", "height" : "80px", "top": "30px", "left" : "80px"}); } } <script src="http://code.jquery.com/jquery-1.9.1.js"></script> css//the js file.. var person1; function getdata() { person1=prompt("Please enter your data 1","Sample 1",max="5"); } function displayResult() { var table1=document.getElementById("table1"); table1.innerHTML=person1; if(person1.value!="") { $("#table1").css({"border-color": "#000000", "border-width":"1px", "border-style":"solid", "visibility" : "visible", //"position" :"fixed", //"resize":"both", "overflow":"auto", "width":"60px", //"maxlength":"10", "height": "80px", "top": "30px", "left" : "80px"}); } else { alert("hello"); ("#table1").css({"border-color": "#000000", "border-width":"0px", "border-style":"solid", "visibility" : 'hidden', //"position" :"fixed", "resize":"both", "overflow":"auto", "width" :"60px", "height" : "80px", "top": "30px", "left" : "80px"}); } } Difficulty in making DIV Make div hidden when no input is given
I am making a box using a div tag.Input User input will be taken from the user from a prompt-box and will be displayed in a box made out of a div tag of fixed dimensions.If If no input has been given then the boxdiv will not be displayed at all.
The problem i am facing is thatHowever, when iI do not enter anything in the prompt-box, the empty div box is still getting displayed, even though iI have specified an elseelse condition where I have made it'sin which its visibility is set to hidden..
I think Thethe program is not entering the elseelse condition of the ifif statement to takeset the visibility style of the div as hidden..
Help needed..
Here is my code..
Javascript codeJavaScript:
HTML CODE...:
<body><form><body> <form> <div id="table1" width="1%" height="10%" style="visibility:hidden"></div> </form> <button type="button" id="button" onclick="getdata()">Insert data</button> </body> Difficulty in making DIV hidden when no input is given
I am making a box using a div tag.Input will be taken from the user from a prompt-box and will be displayed in a box made out of a div tag of fixed dimensions.If no input has been given then the box will not be displayed at all.
The problem i am facing is that when i do not enter anything in the prompt-box the empty div box is still getting displayed even though i have specified an else condition where I have made it's visibility hidden..
I think The program is not entering the else condition of the if statement to take the visibility style of div as hidden..
Help needed..
Here is my code..
Javascript code
HTML CODE...
<body><form> <div id="table1" width="1%" height="10%" style="visibility:hidden"></div> </form> <button type="button" id="button" onclick="getdata()">Insert data</button> </body> Make div hidden when no input is given
I am making a box using a div tag. User input will be taken from a prompt-box and will be displayed in a div tag of fixed dimensions. If no input has been given then the div will not be displayed at all.
However, when I do not enter anything in the prompt-box, the empty div is still displayed, even though I have specified an else condition in which its visibility is set to hidden.
I think the program is not entering the else condition of the if statement to set the visibility of the div as hidden.
JavaScript:
HTML:
<body> <form> <div id="table1" width="1%" height="10%" style="visibility:hidden"></div> </form> <button type="button" id="button" onclick="getdata()">Insert data</button> </body>