Boolean Function To Hide / Show DIV
Mar 20, 2010
I am very new to javascript and html. I am trying to create a function which will hide or show a div (div1). Right now, it is always showing the div whether the boolean value is true or false. I know that it is getting inside the else if part, but it doesn't seem to be working.
<script type="text/javascript">
function hideDiv(flag){
if (flag == false){
document.getElementById('div1').style.visibility="visible";
}else if (flag == true){
document.getElementById(div1).style.visibility="hidden";
}}
var bool = new Boolean(true)
hideDiv(bool);
</script><body>
<div id="div1">
Text!
</div></body>
View 4 Replies
ADVERTISEMENT
Sep 12, 2011
I am trying to hide/show table when hide/show button is pressed
Problem: The code works fine when I remove 'slow' from line 10. But with 'slow' in line 10 content of toggleButton doesnt change from Hide to Show when pressed.
Code:
View 1 Replies
View Related
Jul 23, 2005
I have a simple JS function that I want to return a true or false value
based on the parameter passed in. At this point of time I receive the
error "'True' is undefined". Here is my code below.
JS Function -
function ShowSpecifiedPeriod(pShowPeriod){
document.mfperformance.ShowPeriod.value = pShowPeriod
document.mfperformance.method = 'get'
document.mfperformance.action = 'composite_requestdata.asp'
document.mfperformance.submit();
}
ASP Event Handler -
onclick="ShowSpecifiedPeriod(<%If bShowPeriod = false then
Response.Write true else Response.Write false%>)"
The ASP variable bShowPeriod is set based on the hidden form field
"ShowPeriod" and the initial value is set to false.
More than likely this has to do with the boolean Parameter but I am not
sure how to handle this in JS. I have tried the following but receive
the same results.
function ShowSpecifiedPeriod(boolean pShowPeriod) - Same Error
function ShowSpecifiedPeriod(pShowPeriod boolean) - Same Error
Please let me know what I am doing wrong here.
View 2 Replies
View Related
Nov 9, 2005
I need an 'unobstrusive DOM' function which will show and hide a piece of text within the DIV activated by links. Can anyone help me find a suitable function?
<div id="formatting">
<h3>Formatting options</h3>
<dl>
<dt>Bold</dt>
<dd>[b]text[eb]</dd>
<dt>Italic</dt>
<dd>[i]text[ei]</dd>
<dt>Link</dt>
<dd>link [l=url]text[el]</dd>
<dt>Line break</dt>
<dd>single new line</dd>
<dt>Paragraph</dt>
<dd>double new line</dd>
</dl>
<a href="">Show</a>
<a href="">Hide</a>
</div>
View 24 Replies
View Related
Jul 4, 2011
give me a dive hide show javascript function.
View 1 Replies
View Related
Jan 8, 2003
The below is a menu, which is hidden until clicked, and can be hidden by clicking it again.
<!-- This goes in the HEAD of the html file -->
<script language="javascript">
<!--
function showIt() {
if (document.layers) {document.layers["layer1"].visibility='hide'}
else {document.all["layer1"].style.visibility='hidden'}
}
function hideIt() {
if (document.layers) {document.layers["layer1"].visibility='show'}
else {document.all["layer1"].style.visibility='visible'}
}
// -->
</script>
<style>
input {border-style: ridge;}
a:hover {text-decoration: underline}
</style>
</head>
<body>
<span id="layer" style="position:absolute; top:17; left:20; width:250; height:90; visibility:show">
<script>
<!-- author: bfsog@hotmail.com use it as you wish //-->
<!--
function buttonText(type) {
if (type=="Hide Menu ") {document.menu.button.value="Menu";}
else {document.menu.button.value="Hide Menu ";}
showIt();
if (document.menu.button.value=="Hide Menu ") {hideIt();}
}
// -->
<!-- change the value of 'top' and 'left' in the layers properties below to place the menu
in the desired position matching the placement of the button -->
</script>
<form name="menu">
<input type="button" name="button" onClick="buttonText(value);" value="Show Menu" />
</form>
</span>
<div id="layer1" style="position:absolute; top:40; left:20; width:250; height:90; visibility:hidden">
<table bgcolor="yellow" border="1" cellpadding="2" cellspacing="0">
<tr><td><a href="http://www.google.com" style="text-decoration: none"><font face="arial" size="1"><b>google</b></font></a></td></tr>
<tr><td><a href="http://www.hotmail.com" style="text-decoration: none"><font face="arial" size="1"><b>hotmail</b></font></a></td></tr>
</table>
</div>
</body>
View 1 Replies
View Related
Aug 6, 2009
I have a script to show and hide various divs based on a function & var. The problem I am having is that when ANY of the variables ('hate', 'ok' and 'love') are passed all 3 different feedback forms ('FeedbackHate', 'FeedbackOk' and 'FeedbackLove') appear, not just the one I want.
Here is the JS:
function sitesurveyswitch(emotion) {
var e = emotion;
document.getElementById('site_survey_hate').style.backgroundPosition = '0px 0px';
document.getElementById('site_survey_ok').style.backgroundPosition = '0px 0px';
document.getElementById('site_survey_love').style.backgroundPosition = '0px 0px';
document.getElementById('FeedbackHate').style.display = 'none';
document.getElementById('FeedbackOk').style.display = 'none';
document.getElementById('FeedbackLove').style.display = 'none';
if (e == 'hate')
document.getElementById('site_survey_hate').style.backgroundPosition = '-80px 0px';
document.getElementById('FeedbackHate').style.display = 'block';
if (e == 'ok')
document.getElementById('site_survey_ok').style.backgroundPosition = '-80px 0px';
document.getElementById('FeedbackOk').style.display = 'block';
if (e == 'love')
document.getElementById('site_survey_love').style.backgroundPosition = '-80px 0px';
document.getElementById('FeedbackLove').style.display = 'block';
}
And here is the code related to this function:
<div id="siteSurveyBox">
<span id="site_survey_hate" onclick="sitesurveyswitch('hate');return false;"></span>
<span id="site_survey_ok" onclick="sitesurveyswitch('ok');return false;"></span>
<span id="site_survey_love" onclick="sitesurveyswitch('love');return false;"></span>
</div>
<div id="FeedbackHate" style="display:none; margin-top:-28px;">
FEEDBACK FORM IS HERE
</div>
<div id="FeedbackOk" style="display:none; margin-top:-28px;">
FEEDBACK FORM IS HERE
</div>
<div id="FeedbackLove" style="display:none; margin-top:-28px;">
FEEDBACK FORM IS HERE
</div>
View 2 Replies
View Related
Jun 24, 2010
I have a simple FAQ show/hide function set up however I am having trouble setting up an if clause. My code is:
$(document).ready(function(){
$("dd").hide();
$("dt").click(function(){
$("dd").hide('slow');
$(this).next().slideToggle();
});
});
However, when you click on the same item twice it firstly hides and then reshows it, I need an if statement that basically states;
if "this?!" is visible/shown
Then do nothing
else
$("dd").hide('slow');
$(this).next().slideToggle();
I am unsure of the syntax and can't figure out what property I can trace out to see if the item is being shown or not.
View 4 Replies
View Related
Aug 1, 2011
I am trying to create a simple splash page.
I have 2 divs on the page, div1 has a gif animation in it and div2 is the page content. I want to hide div2 and only show div1 which plays the gif, then after some time div1 fades away and div2 fades up to show the page content.
This is my thought process:
1) On doc ready, hide div2
2) after 3000 fade div1 out
3) fade div2 in
$(document).ready (function(){
$('#div2')hide();
but I dont know how to fade out the div after a time and fade in the other div.
The examples I see all use the click function.
View 1 Replies
View Related
Jul 19, 2009
So in the past I've mostly just copy and pasted other JavaScript functions I needed, and made slight modifications based on my exact needs. However, this time I couldn't find anything that would work with what I wanted to do (show and hide comments on news stories in a particular way), so I decided to just make my own.After a few hours of messing around with it, I'm quite exasperated, because what I have looks like it should work, but for some reason I can't identify, doesn't.Essentially what it should do is, find the table with the ID of the news article whose comments are being toggled, then find all the rows in the table that are labeled as comments, and either show them or hide them, based on their current state (as defined by their class with a "display: none;" in it or not).
Obviously it uses PHP, but I know that's not the problem; it just uses the article's ID number to pass on which comments need to be hidden/shown to the function.From everything I've looked up, this should work, but doesn't. Something peculiar, though, is that the function looks like it's not even being called; I put a simple alert('Test'); in the function, and still nothing happened when I clicked the link. So maybe my function is fine in itself, but I'm just calling it in an incorrect manner?
View 4 Replies
View Related
Feb 2, 2011
Getting my show/hide function to work in all browsers.
The function below works everywhere but Firefox.
Can someone see why it's not working?
My javascript function:
View 6 Replies
View Related
Mar 22, 2010
I'm learning how to use Javascripts and using Prototype framework by following a step by step tutorial from a book. Unfortunately when I stepping through the following code:[code]
View 8 Replies
View Related
Jan 7, 2011
I have a table that Im hiding during the initial load that has a considerable amount of data. (I dont design'em, I just code 'em).
During the .show, .hide ... functions I would like to display a please wait msg. But I cant seem to find a way to do an async function. As the callback functions only deal with sync ...(I think)
View 1 Replies
View Related
Jun 14, 2011
I have a table that contains many rows, some in italian with code <td nome='riga_i'>. and some in english with code <td name='row_e'>. I have created two buttons with different background flags: italy and uk, so when one pushes the button with flag uk, the html page will be reloaded with only english rows, and when one pushes the button with flag it, the same page is reloaded containing only italian rows. All the code posted here works well, but I think that the code can be better because to reach this result I had to dupplicate the same function and I don' t like this.
Here the code:
To better the code I have tried in this way but without success ...
View 2 Replies
View Related
Mar 5, 2011
just started using jQuery,and i'm having a problem using the function .show()/.hide() to make a div appear and disapear when a certain option value is selected.It's working fine in firefox but not working at all in chrome and IE 8.This is the function code i'm using :
$(function(){
$("#produtos").click(function(){
$("#produtos_valor").show("slow");
[code]....
View 3 Replies
View Related
Jul 28, 2009
I have a function that uses the ajax load function to post off some parameters and fill a div with the returned content after a db query has been run to create it. This all works fine, however I would like to be able to replace the div with a loading graphic whilst the content
is generated. I assumed this was done by placing the graphic at the start of the function, then using a callback function to remove it and display the actual data once it has been fully generated...
However when I trey to implement this I am getting a strange result in that the callback fires before the content is generated. So my loading graphic disappears and then the content appears sometimes 10 seconds later. How can I ensure the call back only executes once the new content is
ready to be displayed ??
Here's my code ...
function get_report(){
// Hide #report_here div and show loading graphic here ...
$("#report_here").load("/admin/reports/statistics_report/", {
// Parameters sent go here
}, finished()
);
function finished() {
// Hide loading graphic and show #report_here div here ...
}
View 1 Replies
View Related
Jun 13, 2011
I have a table that contains many rows, some in italian with code <td nome='riga_i'> and some in english with code <td name='row_e'>. I have created two buttons with different background flags: italy and uk, so when one pushes the button with flag uk, the html page will be reloaded with only english rows, and when one pushes the button with flag it, the same page is reloaded containing only italian rows. All the code posted here works well, but I think that the code can be better because to reach this result I had to dupplicate the same function and I don' t like this.
Here the code:
To better the code I have tried in this way but without success ...
View 1 Replies
View Related
Feb 15, 2007
Is there a way to write this simpler?
function makeOpposite(a) {
if(!a) {
a = true;
}
else {
a = false;
}
}
View 10 Replies
View Related
Dec 7, 2010
I'm trying to modify this function code...
which works for a checkbox to one that works for a button.
I guess I'm stuck on what to replace "checked" with there in the 3rd line.
is there some one word answer, or do I need to I rewrite the function to be more button-friendly?
View 5 Replies
View Related
Jan 22, 2009
I am having problems, basically I have a set of nested lists I need to show and hide
Code:
<ul id="smenu3"><ul id="smenu4">
<li>stuff here..</li>
<li>stuff here..</li>
<li>stuff here..</li>
</ul><ul id="smenu5">
[Code]...
I always want "smenu3" to show with "smenu4" and "smenu5" collapsed... When the user clicks the link, it calls a javascript function to show "smenu4" like so...
[Code]...
View 7 Replies
View Related
Dec 24, 2009
I'm trying to get a return boolean or something I could use to then do another asynchronous request have my first has completely finished.
I'm messing around with Javascript on this basic PHP blog I built and I have a table of articles and one of the table columns is published/unpublished. I'm trying to have when they click the icon it will connect to MySQL, update the current row with new publish value (opposite of current) then refresh the div id element that the publish/unpublish icon is in to reveal the new status. I built a class for my javascript requests so most values are stored in global properties.
I think what I'm coming across is when I click the icon it updates the table but before that onreadystatechange can hit 4 my request for the new content is going through so the request url I'm using as well as the return div id for the responseText are getting mixed up between trying to do a sql update, loading the responseText in "message" then trying to sql query for the new results and loading that responseText in "content".
Something like..
url = "?table=articles&value=1&id=2";
http.onreadystatechange = this.stateChange;
http.open("GET" , url , true)
[Code]....
View 2 Replies
View Related
Apr 22, 2009
I have a list that looks like this:
<ul id="thisList">
<li class="this0">content</li>
<li class="this1">content</li>
<li class="this1">content</li>
[Code].....
View 4 Replies
View Related
Aug 11, 2005
I am trying to hide some form elements in a form by default and show/hide
depending on which radio button is clicked. This is what I have but it is
not working: Code:
View 2 Replies
View Related
Sep 6, 2005
I'd like to have a show/hide widget on my web site, kind of like "show
details" / "hide details" in Google Groups. Is there a tutorial
explaining how to make them? Google's is a bit complex and it's easy to
get something wrong. If the browser does not support the required
features, I want it to generate a completely static page with the
"details" shown automatically.
View 3 Replies
View Related
Oct 26, 2009
Check this code:
<a>text</a>
<div id="pkg">pkg</div>
<div id="table_pkg">table_pkg</div>
I'd like to show table_pkg and hide pkg when I click on <a>text</a>. How can I do?
View 3 Replies
View Related
Apr 8, 2009
I am using some simple javascript to show and a hide a div
Code:
function showHide(d) {
if (document.getElementById(d).style.display == "none")
{
document.getElementById(d).style.display = "block";
[Code]...
View 5 Replies
View Related