473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PHP with Style="Display:None"?

chunk1978
224 100+
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 28829
Motoma
3,237 Expert 2GB
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 100+
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 Expert 2GB
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 100+
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 Expert 2GB
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 100+
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
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...
5
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...
2
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) ...
15
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...
2
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...
1
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,...
3
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...
4
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
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.