On page load: Only show specific information
up vote
1
down vote
favorite
I have a page that is going to have many many toggles on it, some created dynamically. I was wondering if I could load a page, which shows only a specific div, but the moment the user clicks a button a toggle is created (done this part) and the user is unable to see the version of the page that only shows one specific div unless they delete all the other content on the page.
I do not know if I have explained that well at all:
Start off showing only this content

On clicking the save button only show this...

My code does part of this already. Just honestly cannot work out how to even start the on page load part. I have looked at the jQuery on page load function but don't know if this is the best or only route.
//hide text onclick
$(document).ready(function() {
var $p = $('p#menu_title');
$("input#save_first_prod").click(function(event) {
event.preventDefault();
$p.css('display', 'none');
});
});
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block' || e.style.display == '')
e.style.display = 'none';
else
e.style.display = 'block';
}.hidden {
display: visible;
}
div#first_product{
width: 50%;
margin-left: 301px;
}
div#red_head{
background-color: #ed1c24;
height: 40px;
color: #fff;
padding-left: 15px;
line-height: 35px;
}
div#first_product{
background-color: #f1f1f2;
height: 100%;
}
h3#menu{
color: #6d6e70;
padding-left: 15px;
}
/*OUTSIDE TOGGLE BUTTON*/
#products_tog_but{
background-color: #f8f9f9;
border: 1.5px dashed #999999;
width: 100%;
height: 40px;
border-radius: 5px;
}
div#hide_btn{
width:50%;
margin-left: 301px;
}div id="hide_btn">
<button id="products_tog_but" onclick="toggle_visibility('first_product')">Hello!</button>
</div>
<!-- TOGGLE BTN SECTION-->
<div id="first_product">
<div id="red_head">
<p id="menu_title" class ="hidden" onclick="hideText('text1')" > Add your first menu item</p>
</div>
<h3 id="menu">Menu Section</h3>
<form name="first_prod" id="first_prod" enctype="multipart/form-data" action="testing.php" method="post" accept-charset="utf-8" >
<label id="cat_label" name="cat_label">Name</label>
<input type="text" id="cat_name" name="cat_name" value="">
<label id="desc_label" name="desc_label">Description</label>
<input type="text" id="cat_desc" name="cat_desc" value="">
<input type="Submit" id="save_first_prod" name="save_first_prod" onclick="toggle_visibility('first_product')" value=" + ADD">
</form>
</div>javascript jquery html
add a comment |
up vote
1
down vote
favorite
I have a page that is going to have many many toggles on it, some created dynamically. I was wondering if I could load a page, which shows only a specific div, but the moment the user clicks a button a toggle is created (done this part) and the user is unable to see the version of the page that only shows one specific div unless they delete all the other content on the page.
I do not know if I have explained that well at all:
Start off showing only this content

On clicking the save button only show this...

My code does part of this already. Just honestly cannot work out how to even start the on page load part. I have looked at the jQuery on page load function but don't know if this is the best or only route.
//hide text onclick
$(document).ready(function() {
var $p = $('p#menu_title');
$("input#save_first_prod").click(function(event) {
event.preventDefault();
$p.css('display', 'none');
});
});
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block' || e.style.display == '')
e.style.display = 'none';
else
e.style.display = 'block';
}.hidden {
display: visible;
}
div#first_product{
width: 50%;
margin-left: 301px;
}
div#red_head{
background-color: #ed1c24;
height: 40px;
color: #fff;
padding-left: 15px;
line-height: 35px;
}
div#first_product{
background-color: #f1f1f2;
height: 100%;
}
h3#menu{
color: #6d6e70;
padding-left: 15px;
}
/*OUTSIDE TOGGLE BUTTON*/
#products_tog_but{
background-color: #f8f9f9;
border: 1.5px dashed #999999;
width: 100%;
height: 40px;
border-radius: 5px;
}
div#hide_btn{
width:50%;
margin-left: 301px;
}div id="hide_btn">
<button id="products_tog_but" onclick="toggle_visibility('first_product')">Hello!</button>
</div>
<!-- TOGGLE BTN SECTION-->
<div id="first_product">
<div id="red_head">
<p id="menu_title" class ="hidden" onclick="hideText('text1')" > Add your first menu item</p>
</div>
<h3 id="menu">Menu Section</h3>
<form name="first_prod" id="first_prod" enctype="multipart/form-data" action="testing.php" method="post" accept-charset="utf-8" >
<label id="cat_label" name="cat_label">Name</label>
<input type="text" id="cat_name" name="cat_name" value="">
<label id="desc_label" name="desc_label">Description</label>
<input type="text" id="cat_desc" name="cat_desc" value="">
<input type="Submit" id="save_first_prod" name="save_first_prod" onclick="toggle_visibility('first_product')" value=" + ADD">
</form>
</div>javascript jquery html
are you trying to show something on loading time (before the$(document).readyfunction) or just on first interaction? You might need to clarify your question. it's not easy to understand what you're trying to achieve
– Thatkookooguy
Nov 8 at 9:10
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have a page that is going to have many many toggles on it, some created dynamically. I was wondering if I could load a page, which shows only a specific div, but the moment the user clicks a button a toggle is created (done this part) and the user is unable to see the version of the page that only shows one specific div unless they delete all the other content on the page.
I do not know if I have explained that well at all:
Start off showing only this content

On clicking the save button only show this...

My code does part of this already. Just honestly cannot work out how to even start the on page load part. I have looked at the jQuery on page load function but don't know if this is the best or only route.
//hide text onclick
$(document).ready(function() {
var $p = $('p#menu_title');
$("input#save_first_prod").click(function(event) {
event.preventDefault();
$p.css('display', 'none');
});
});
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block' || e.style.display == '')
e.style.display = 'none';
else
e.style.display = 'block';
}.hidden {
display: visible;
}
div#first_product{
width: 50%;
margin-left: 301px;
}
div#red_head{
background-color: #ed1c24;
height: 40px;
color: #fff;
padding-left: 15px;
line-height: 35px;
}
div#first_product{
background-color: #f1f1f2;
height: 100%;
}
h3#menu{
color: #6d6e70;
padding-left: 15px;
}
/*OUTSIDE TOGGLE BUTTON*/
#products_tog_but{
background-color: #f8f9f9;
border: 1.5px dashed #999999;
width: 100%;
height: 40px;
border-radius: 5px;
}
div#hide_btn{
width:50%;
margin-left: 301px;
}div id="hide_btn">
<button id="products_tog_but" onclick="toggle_visibility('first_product')">Hello!</button>
</div>
<!-- TOGGLE BTN SECTION-->
<div id="first_product">
<div id="red_head">
<p id="menu_title" class ="hidden" onclick="hideText('text1')" > Add your first menu item</p>
</div>
<h3 id="menu">Menu Section</h3>
<form name="first_prod" id="first_prod" enctype="multipart/form-data" action="testing.php" method="post" accept-charset="utf-8" >
<label id="cat_label" name="cat_label">Name</label>
<input type="text" id="cat_name" name="cat_name" value="">
<label id="desc_label" name="desc_label">Description</label>
<input type="text" id="cat_desc" name="cat_desc" value="">
<input type="Submit" id="save_first_prod" name="save_first_prod" onclick="toggle_visibility('first_product')" value=" + ADD">
</form>
</div>javascript jquery html
I have a page that is going to have many many toggles on it, some created dynamically. I was wondering if I could load a page, which shows only a specific div, but the moment the user clicks a button a toggle is created (done this part) and the user is unable to see the version of the page that only shows one specific div unless they delete all the other content on the page.
I do not know if I have explained that well at all:
Start off showing only this content

On clicking the save button only show this...

My code does part of this already. Just honestly cannot work out how to even start the on page load part. I have looked at the jQuery on page load function but don't know if this is the best or only route.
//hide text onclick
$(document).ready(function() {
var $p = $('p#menu_title');
$("input#save_first_prod").click(function(event) {
event.preventDefault();
$p.css('display', 'none');
});
});
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block' || e.style.display == '')
e.style.display = 'none';
else
e.style.display = 'block';
}.hidden {
display: visible;
}
div#first_product{
width: 50%;
margin-left: 301px;
}
div#red_head{
background-color: #ed1c24;
height: 40px;
color: #fff;
padding-left: 15px;
line-height: 35px;
}
div#first_product{
background-color: #f1f1f2;
height: 100%;
}
h3#menu{
color: #6d6e70;
padding-left: 15px;
}
/*OUTSIDE TOGGLE BUTTON*/
#products_tog_but{
background-color: #f8f9f9;
border: 1.5px dashed #999999;
width: 100%;
height: 40px;
border-radius: 5px;
}
div#hide_btn{
width:50%;
margin-left: 301px;
}div id="hide_btn">
<button id="products_tog_but" onclick="toggle_visibility('first_product')">Hello!</button>
</div>
<!-- TOGGLE BTN SECTION-->
<div id="first_product">
<div id="red_head">
<p id="menu_title" class ="hidden" onclick="hideText('text1')" > Add your first menu item</p>
</div>
<h3 id="menu">Menu Section</h3>
<form name="first_prod" id="first_prod" enctype="multipart/form-data" action="testing.php" method="post" accept-charset="utf-8" >
<label id="cat_label" name="cat_label">Name</label>
<input type="text" id="cat_name" name="cat_name" value="">
<label id="desc_label" name="desc_label">Description</label>
<input type="text" id="cat_desc" name="cat_desc" value="">
<input type="Submit" id="save_first_prod" name="save_first_prod" onclick="toggle_visibility('first_product')" value=" + ADD">
</form>
</div> //hide text onclick
$(document).ready(function() {
var $p = $('p#menu_title');
$("input#save_first_prod").click(function(event) {
event.preventDefault();
$p.css('display', 'none');
});
});
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block' || e.style.display == '')
e.style.display = 'none';
else
e.style.display = 'block';
}.hidden {
display: visible;
}
div#first_product{
width: 50%;
margin-left: 301px;
}
div#red_head{
background-color: #ed1c24;
height: 40px;
color: #fff;
padding-left: 15px;
line-height: 35px;
}
div#first_product{
background-color: #f1f1f2;
height: 100%;
}
h3#menu{
color: #6d6e70;
padding-left: 15px;
}
/*OUTSIDE TOGGLE BUTTON*/
#products_tog_but{
background-color: #f8f9f9;
border: 1.5px dashed #999999;
width: 100%;
height: 40px;
border-radius: 5px;
}
div#hide_btn{
width:50%;
margin-left: 301px;
}div id="hide_btn">
<button id="products_tog_but" onclick="toggle_visibility('first_product')">Hello!</button>
</div>
<!-- TOGGLE BTN SECTION-->
<div id="first_product">
<div id="red_head">
<p id="menu_title" class ="hidden" onclick="hideText('text1')" > Add your first menu item</p>
</div>
<h3 id="menu">Menu Section</h3>
<form name="first_prod" id="first_prod" enctype="multipart/form-data" action="testing.php" method="post" accept-charset="utf-8" >
<label id="cat_label" name="cat_label">Name</label>
<input type="text" id="cat_name" name="cat_name" value="">
<label id="desc_label" name="desc_label">Description</label>
<input type="text" id="cat_desc" name="cat_desc" value="">
<input type="Submit" id="save_first_prod" name="save_first_prod" onclick="toggle_visibility('first_product')" value=" + ADD">
</form>
</div> //hide text onclick
$(document).ready(function() {
var $p = $('p#menu_title');
$("input#save_first_prod").click(function(event) {
event.preventDefault();
$p.css('display', 'none');
});
});
function toggle_visibility(id) {
var e = document.getElementById(id);
if (e.style.display == 'block' || e.style.display == '')
e.style.display = 'none';
else
e.style.display = 'block';
}.hidden {
display: visible;
}
div#first_product{
width: 50%;
margin-left: 301px;
}
div#red_head{
background-color: #ed1c24;
height: 40px;
color: #fff;
padding-left: 15px;
line-height: 35px;
}
div#first_product{
background-color: #f1f1f2;
height: 100%;
}
h3#menu{
color: #6d6e70;
padding-left: 15px;
}
/*OUTSIDE TOGGLE BUTTON*/
#products_tog_but{
background-color: #f8f9f9;
border: 1.5px dashed #999999;
width: 100%;
height: 40px;
border-radius: 5px;
}
div#hide_btn{
width:50%;
margin-left: 301px;
}div id="hide_btn">
<button id="products_tog_but" onclick="toggle_visibility('first_product')">Hello!</button>
</div>
<!-- TOGGLE BTN SECTION-->
<div id="first_product">
<div id="red_head">
<p id="menu_title" class ="hidden" onclick="hideText('text1')" > Add your first menu item</p>
</div>
<h3 id="menu">Menu Section</h3>
<form name="first_prod" id="first_prod" enctype="multipart/form-data" action="testing.php" method="post" accept-charset="utf-8" >
<label id="cat_label" name="cat_label">Name</label>
<input type="text" id="cat_name" name="cat_name" value="">
<label id="desc_label" name="desc_label">Description</label>
<input type="text" id="cat_desc" name="cat_desc" value="">
<input type="Submit" id="save_first_prod" name="save_first_prod" onclick="toggle_visibility('first_product')" value=" + ADD">
</form>
</div>javascript jquery html
javascript jquery html
edited Nov 8 at 8:43
Flimzy
36.6k96496
36.6k96496
asked Apr 10 '16 at 14:11
Monroe
927
927
are you trying to show something on loading time (before the$(document).readyfunction) or just on first interaction? You might need to clarify your question. it's not easy to understand what you're trying to achieve
– Thatkookooguy
Nov 8 at 9:10
add a comment |
are you trying to show something on loading time (before the$(document).readyfunction) or just on first interaction? You might need to clarify your question. it's not easy to understand what you're trying to achieve
– Thatkookooguy
Nov 8 at 9:10
are you trying to show something on loading time (before the
$(document).ready function) or just on first interaction? You might need to clarify your question. it's not easy to understand what you're trying to achieve– Thatkookooguy
Nov 8 at 9:10
are you trying to show something on loading time (before the
$(document).ready function) or just on first interaction? You might need to clarify your question. it's not easy to understand what you're trying to achieve– Thatkookooguy
Nov 8 at 9:10
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f36530824%2fon-page-load-only-show-specific-information%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
are you trying to show something on loading time (before the
$(document).readyfunction) or just on first interaction? You might need to clarify your question. it's not easy to understand what you're trying to achieve– Thatkookooguy
Nov 8 at 9:10