473,545 Members | 1,224 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 28914
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
40641
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...
5
9814
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...
2
9590
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
8898
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
8676
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>...
1
2354
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...
3
2388
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
2040
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
10149
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;...
0
7465
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...
0
7656
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. ...
1
7416
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7752
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...
1
5325
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...
0
4944
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...
0
3449
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1878
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.