Style display none in php

Скрыть div по id в php

Но вот в чем беда, если пользователь решил пройти по какой-то категории, то этот «фильтр» сбрасывается (т.е. ему надо еще раз нажать на кнопку чтобы скрыть ненужные ему категории). Я хотел бы чтобы либо это запоминалось как-то в JS (хотя не могу до этого пока дойти), либо чтобы при нажатии на кнопку пользователю выдавались div’ы с определенным (заранее мною определенным) id.

Задача вроде не трудная, но т.к. знаний у меня — не очень, прошу помощи. МОжет на JS и быстрее, но как сделать чтобы результат запоминался?!(

Скрыть блок div методом PHP
Доброго времени суток, как сделать так что бы при нажатии <input type="button"> скрывался блок <div.

Скрыть div и заменить class
Подскажите пожалуйста как правильно реализовать следующее: Есть такой кусок верстки: <div.

Скрыть div после успешной авторизации
Все привет! В общем имеется код(смотрите ниже). Так вот, как сделать так, чтобы после.

скрыть div, а на его место поставить другой
Помогите пожалуйста. Есть 2 блока #active и #activeout Нужно без помощи javascript сделать так.

1. Использовать куки
либо
2. использовать сесии в PHP
либо
3. использовать БД, записывать в нее то что пользователь скрыл/не скрыл

На php будет быстрее! Он срабатывает быстрее чем js, с js скрываться элементы будут только после загрузки страницы.
Установка кук
http://php.net/manual/ru/function.setcookie.php
В вашем случае всего скорее лучше содержимое куки приготовить примерно в таком виде

// Если найдено вхождение по id if($poisk_v_ctroke) { $close = 'style="display:none'; } else { $close = ''; }

Источник

Скрытие Div с помощью php

В настоящее время я скрываю div, основанный на выражении if. Метод, который я использую, использует echo out a css стиль display: none Вот что я делаю конкретно:

Мой вопрос: это хороший метод для скрытия div? Возможно ли, что браузер кэширует стиль и поэтому игнорирует стиль echo -ed out css ?

Вы можете просто не включать div вообще. но я не понимаю, что вы имеете в виду в отношении кешируемого стиля.

Встроенные стили кэшируются вместе со страницей, а не в одиночку. Если это хорошо или нет, это зависит от вашего вопроса, и в нем недостаточно информации, чтобы правильно судить об уровне хорошего, который я бы сказал.

. или вы можете дать div только имя класса, которое применяет display: none если вы хотите его скрыть. Или даже встроенный стиль.

@Dagon хорошо вы знаете, как браузер хранит фрагменты html, такие как стиль изображений и т. Д., Чтобы загружать страницу быстрее, если пользователь снова возвращается.

Вот хороший вопрос о динамически генерируемых CSS с плюсами и минусами stackoverflow.com/questions/11853063/…

@VidhuShresthBhatnagar — Браузеры кэшируют изображения и т. Д., Но я никогда не знал, чтобы браузер кэшировал HTML так, как вы, кажется, думаете. Первоначальный комментарий Dagons — это обычный метод, он также чище при просмотре кода, а также быстрее, если в этом div может быть много контента.

6 ответов

Использование Php в CSS (Cascade Style Sheet) не является «правильным»,

Кроме того, вы можете использовать Php в своем HTML:

С помощью этого кода блок div не отображается (и вы не используете его с JavaScript), вы можете использовать это для просто скрытого div:

Читайте также:  Панель с кнопками css

Мне также нравится первое решение, но я не знаю, как его реализовать . какой будет полный код, который я могу вставить в файл .php, чтобы увидеть его в действии? Это часть (условия), с которой у меня проблема

Почему бы не создать класс:

И чем применить его с PHP:

Как еще вы могли бы скрыть это, кроме использования встроенного стиля? И я тоже считаю, что это не «семантический» класс. Я предположил, что ОП хотел, чтобы div был скрыт и не был удален со страницы, потому что он использовал display:none в вопросе уже display:none . 🙂

Это не лучший способ скрыть div. Поскольку PHP разбирается на стороне сервера, вы можете также включить оператор if или исключить div вместо эхо-значения класса CSS. Единственный раз, когда было бы полезно использовать класс CSS, — если вы планируете использовать JavaScript для отображения div на странице позже, в то время как пользователь находится на самой странице.

Источник

PHP with Style=»Display:None»?

i’m about to embark on my very first PHP code journey (i’ve been saying that for a while. so sometime soon i hope. anyway).

before i begin my exciting new journey into PHP land, i would like to know if PHP will send hidden HTML form elements or not.

for example: if a user makes a selection in my HTML form that triggers my wonderfully dynamic HTML to set a DIV to STYLE=»DISPLAY:NONE», is it possible to tell PHP not to send the DIV’s data if it’s hidden (even-though there will be a »

for me, setting STYLE=»DISPLAY:NONE» or STYLE=»DISPLAY:BLOCK» is as easy as pie. but removing and appending children, well. that’s a little confusing.

i’m about to embark on my very first PHP code journey (i’ve been saying that for a while. so sometime soon i hope. anyway).

before i begin my exciting new journey into PHP land, i would like to know if PHP will send hidden HTML form elements or not.

for example: if a user makes a selection in my HTML form that triggers my wonderfully dynamic HTML to set a DIV to STYLE=»DISPLAY:NONE», is it possible to tell PHP not to send the DIV’s data if it’s hidden (even-though there will be a »

for me, setting STYLE=»DISPLAY:NONE» or STYLE=»DISPLAY:BLOCK» is as easy as pie. but removing and appending children, well. that’s a little confusing.

Display:none is effects the rendering of the page. PHP gets executed before the page ever existed. If you know that a section of the page will never be there, you can just not send it. But, after the page has been sent to the browser, you cannot modify it with php (at least not without the help of ajax). DOM would be your best bet here, as gruesome as that is.

Display:none is effects the rendering of the page. PHP gets executed before the page ever existed. If you know that a section of the page will never be there, you can just not send it. But, after the page has been sent to the browser, you cannot modify it with php (at least not without the help of ajax). DOM would be your best bet here, as gruesome as that is.

humm. ok. what about if the field/dropmenu contains no data (is blank) or value («options[0].selected=true»). will PHP still display these blank fields, regardless if they’re hidden or not?

humm. ok. what about if the field/dropmenu contains no data (is blank) or value («options[0].selected=true»). will PHP still display these blank fields, regardless if they’re hidden or not?

i’m clearly getting ahead of myself as i don’t really understand. ok. so the code below is a perfect example of what i mean exactly.

Читайте также:  Посчитать количество отрицательных элементов массива python

so even if the html isn’t displaying the name field, will PHP still print/echo it with the PHP output. or is there a way to write the PHP tag a certain way to tell it that if the HTML field is hidden, don’t echo. maybe something like this:

Источник

Скрыть div по id в php

Но вот в чем беда, если пользователь решил пройти по какой-то категории, то этот «фильтр» сбрасывается (т.е. ему надо еще раз нажать на кнопку чтобы скрыть ненужные ему категории). Я хотел бы чтобы либо это запоминалось как-то в JS (хотя не могу до этого пока дойти), либо чтобы при нажатии на кнопку пользователю выдавались div’ы с определенным (заранее мною определенным) id.

Задача вроде не трудная, но т.к. знаний у меня — не очень, прошу помощи. МОжет на JS и быстрее, но как сделать чтобы результат запоминался?!(

Скрыть блок div методом PHP
Доброго времени суток, как сделать так что бы при нажатии <input type="button"> скрывался блок <div.

Скрыть div и заменить class
Подскажите пожалуйста как правильно реализовать следующее: Есть такой кусок верстки: <div.

Скрыть div после успешной авторизации
Все привет! В общем имеется код(смотрите ниже). Так вот, как сделать так, чтобы после.

скрыть div, а на его место поставить другой
Помогите пожалуйста. Есть 2 блока #active и #activeout Нужно без помощи javascript сделать так.

1. Использовать куки
либо
2. использовать сесии в PHP
либо
3. использовать БД, записывать в нее то что пользователь скрыл/не скрыл

На php будет быстрее! Он срабатывает быстрее чем js, с js скрываться элементы будут только после загрузки страницы.
Установка кук
http://php.net/manual/ru/function.setcookie.php
В вашем случае всего скорее лучше содержимое куки приготовить примерно в таком виде

// Если найдено вхождение по id if($poisk_v_ctroke) { $close = 'style="display:none'; } else { $close = ''; }

Источник

Php error display none in php

If you intent to hide a single post you give unique ids to divs, and call with id of that post. When I set the visibility to hidden in CSS using jQuery it automaticlly adds an when I look at the code in Google Chrome’s inspector.

Is display none gives value on $_POST?

which value of test_val will be POST?

Hiding field in any way won’t hide the value. If you want to prevent value from being sent, your field has to have «disabled» attribute. If you want to access both fields values (and have a same name) then you have to update your names. For example:

Then, in PHP you can access your field values:

$_POST['test_val'][0] == 5 $_POST['test_val'][1] == 10 
 You will get output like below 

PHP Warning: Cannot modify header information need error solving, This output could be HTML mark-up or other output from your PHP, it could even be a blank space at the start of your php file or a Byte Order

Читайте также:  Beremeni ru oslozhneniya kakova norma khgch pri beremennosti html

PHP and jQuery display:none

I am trying to display an error text using jQuery, when the username field is blank. This is not the problem, because I have done this already. The problem is that after the error text shows, I want to click the username field and hide the error text div, so that I can be able to reshow the error if the field is still blank using jQuery.

When I set the visibility to hidden in CSS using jQuery it automaticlly adds an display: hidden when I look at the code in Google Chrome’s inspector.

The code is in: http://albsocial.net84.net/

 
Are you a member? Login .

And enjoy hundreds of services.

Sign up Below .

Easy, fast and free!

and the code im using to actually show or create the error code

$(document).ready(function()< $('.form').submit(function(e) < register(); e.preventDefault(); >); $('.login_form').submit(function(e) < login(); e.preventDefault(); >); >); function register() < hideshow('loading',1); error(0); $.ajax(< type: "POST", url: "php/register.php", data: $('.form').serialize(), dataType: "json", success: function(msg)< if(parseInt(msg.status)==1)< window.location=msg.txt; >else if(parseInt(msg.status)==0) < error(1,msg.txt); >hideshow('loading',0); > >); > function login() < hideshow1('loading1',1); error1(0); $.ajax(< type: "POST", url: "php/login.php", data: $('.login_form').serialize(), dataType: "json", success: function(msg1)< if(parseInt(msg1.status1)==1)< window.location=msg1.txt1; >else if (parseInt(msg1.status1) == 0) < error1(1,msg1.txt1); >hideshow1('loading1',0) > >); > function hideshow(el,act) < if(act) $('#'+el).css('visibility','visible'); else $('#'+el).css('visibility','hidden'); >function error(act,txt) < hideshow('error',act); if(txt) $('#error').html(txt); >function hideshow1(el,act) < if(act) $('#'+el).css('visibility','visible'); else $('#'+el).css('visibility','hidden'); >function error1(act,txt1)
$('#error1').fadeOut('fast', function () < $(this).show() $(this).css("visibility","hidden") >) 

because fadeOut sets display:none; and you are also working with the visibility attribute, get rid of visibility and use .show() and .hide() instead

Doing a .css(‘display’, ‘none’); and .css(‘display’, ‘block’) to hide/show should work fine.

An alternative would be to set the .html(») to remove the text from within the div (thus causing it to hide). Then you wouldn’t need to worry about the visibility of the div.

Showing all errors and warnings, Display errors could be turned off in the php.ini or your Apache configuration file. You can turn it on in the script:

JS Display none with PHP foreach only working with first elemnt

I’m bringing articles from a database with ORDER BY RAND() with a PHP foreach cycle:

  

/profile.php?user=">


/post.php?p=">

As you can see, the div with the class x_hover has an onclick attribute:

What the hide_post() function does is this:

var post = document.getElementsByClassName("post"); function hide_post() < if (post[0].style.display = "block") < post[0].style.display = "none" >> 

I’m new to JS so I have some issues as well.

We are declaring that var post is equal to all the elements with the class name «post», such as the HTML code I added at the beginning, has the class post :

This div has the display: block; attribute. However, when I run all this code, It only turns into display: none the first element that brings us from the database, it doesn’t works with the rest of them.

IDs must be unique and since you have named all of the post only the first one will ever been «seen». Make the IDs unique, change your hide_post function to accept a ID name to hide, and add the unique ID to your onclick calls.

Источник

Оцените статью