473,786 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP with Style="Display: None"?

chunk1978
224 New Member
hi there...

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 "<?PHP" tag on that line)? or is true that the only real way around this to use the DOM method with Remove Child and Append Child?

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...

so what are my options?
Feb 7 '07 #1
6 29299
Motoma
3,237 Recognized Expert Specialist
hi there...

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 "<?PHP" tag on that line)? or is true that the only real way around this to use the DOM method with Remove Child and Append Child?

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...

so what are my options?
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.
Feb 7 '07 #2
chunk1978
224 New Member
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?
Feb 7 '07 #3
Motoma
3,237 Recognized Expert Specialist
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?
Those fields won't exist until PHP creates them.
Feb 7 '07 #4
chunk1978
224 New Member
Those fields won't exist until PHP creates them.
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...

HTML form:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <form action="phpscript.php" method="post">
  4. Name: <input type="text" name="name" style="display:none"/>
  5. <input type="submit" />
  6. </form>
  7. </body>
  8. </html>
  9.  
PHP script:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. Welcome <?php echo $_POST["name"]; ?>.<br />
  4. </body>
  5. </html>
  6.  
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:

Expand|Select|Wrap|Line Numbers
  1. <if (form.name.value = "" || form.name.display.none=true) {<?php echo $_POST["name"]; ?>.}<br />
  2.  
Feb 7 '07 #5
Motoma
3,237 Recognized Expert Specialist
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...

HTML form:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <form action="phpscript.php" method="post">
  4. Name: <input type="text" name="name" style="display:none"/>
  5. <input type="submit" />
  6. </form>
  7. </body>
  8. </html>
  9.  
PHP script:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. Welcome <?php echo $_POST["name"]; ?>.<br />
  4. </body>
  5. </html>
  6.  
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:

Expand|Select|Wrap|Line Numbers
  1. <if (form.name.value = "" || form.name.display.none=true) {<?php echo $_POST["name"]; ?>.}<br />
  2.  
Nope.
The only thing you can tell about a form that has posted to you is the actual address the post came from, and the data that has been posted (i.e. the values of the fields).
However, you could have an input of type HIDDEN that gets changed via Javascript to reflect whether the field is visible, and post that along with the form.
Feb 7 '07 #6
chunk1978
224 New Member
so what your saying is that if the HTML was written like this:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <form action="phpscript.php" method="post">
  4. Name: <input type="text" name="name" style="hidden"/>
  5. <input type="submit" />
  6. </form>
  7. </body>
  8. </html>
  9.  
and if javascript didn't change the hidden field (hidden=true) by the time the form is submitted to the PHP script, than a <?PHP tag on the name file wouldn't echo anything?
Feb 7 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

13
40767
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
5
9825
by: Sue | last post by:
Help! I have an asp table with an embedded table. The asp tablerow that contains this table has a static ID assigned of "FilterRow2" (see snippets of code below). When I click on the button to set the tablerow style property to "None", the row (And embedded table) briefly disappear, but then bounce right back into sight. Any ideas on why it's doing this and how to make the style.display = "None" stick?
2
9611
by: Good Man | last post by:
Hi there I have quite a bit of experience with CSS but I am stumped by the following: http://www.electricphase.com/example/example1.php (uses http://www.electricphase.com/example/test1.css) http://www.electricphase.com/example/example2.php (uses http://www.electricphase.com/example/test2.css)
15
8956
by: pbd22 | last post by:
Hi. I want to create a tab with a little "active tab" arrow below it to tell the user where they are. An example is here: http://personals.yahoo.com/us/search/dashboard Does anybody know of any examples out there on how to do this? Thanks!
2
8687
by: Steve Richter | last post by:
I would like to use display:inline and other CSS attributes to build an entry form. Where the heading to the left of the text box is always a set width. It is not working so I am experimenting with two divs to get them to render side by side: <div style="width:12em;border: 2px solid #EFCE8C; padding: 0.5em;display:inline;">abc</div> <div style="width:12em;border: 2px solid #EFCE8C; padding:
1
2377
by: =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post by:
Hi, I have a webpage designed with asp.net 2.0. Is there a way to display a "please wait" message to the screen horizontally centered and veritcally 20px from the VISIBLE top of the page, regardless of what kind of scrolling the user has done? I am currently displaying a "please wait" message (the DIV section shown below, which i'm showing/hiding) when the user clicks save, but the user is
3
2414
by: bhavyagupt | last post by:
i 'm not able to use the accordion menu code in for loop . can anyone solve ma problem. code....... slider.js------> java script var slider=function(){ var array=; var speed=10; var timer=10; return{ init:function(t,c){
4
2063
by: makweatan | last post by:
Hello, Can anyone please help me, where did I go wrong..? Line : 388 Char : 1 Error : Object Expected Code : 0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
10172
by: shunia | last post by:
I try to use the display style property to show and hide a div.but it doesn't work in IE,FF and Chrome works fine.And there are no bugs in other js code and the text page in the codes below. The style code is here : .ad_div{ border: 1px solid #ccc; display: none; z-index: 1001; width: 650px; height: 470px; position: absolute; background-color:white } .ad_iframe{ border: none; width: 649px; height: 469px } html code is here: <div...
0
9650
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10363
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9962
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8992
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7515
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6748
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.