473,324 Members | 2,214 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,324 software developers and data experts.

Hide/Show PHP Values

chunk1978
224 100+
hello,

i would like to know if it's possible to hide PHP values that come back empty (text fields) or have a specific value (select menus)...

on my form, there are input fields that are optional, so when the PHP processes the form, i'd like not to see a blank field with nothing written...

i'm trying to combine JavaScript with DIV displays to make this happen, but of-course, it doesn't work... i'm just a novice afterall...

this is what i have:

javascript code:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function HideEmptyFields()
  4.     {
  5.     if (document.addressline2.value != "") {document.getElementById('DIVaddressline2').style.display == 'block';
  6.     }
  7.  
  8. </script>
  9.  
then there is an onLoad event handler on the body tag:
Expand|Select|Wrap|Line Numbers
  1. <body onload="HideEmptyFields();">
  2.  
finally... in the PHP portion of the code, i have it written like this:

Expand|Select|Wrap|Line Numbers
  1. <div id="DIVaddressline2" style="display:none;"><?php echo $_POST["addressline2"] ; ?></div><br>
  2.  
is it not possible to hide a DIV with a <?php script inside?

thanks in advance.
Feb 22 '07 #1
7 3326
The1corrupted
134 100+
hello,

i would like to know if it's possible to hide PHP values that come back empty (text fields) or have a specific value (select menus)...

on my form, there are input fields that are optional, so when the PHP processes the form, i'd like not to see a blank field with nothing written...

i'm trying to combine JavaScript with DIV displays to make this happen, but of-course, it doesn't work... i'm just a novice afterall...

this is what i have:

javascript code:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3. function HideEmptyFields()
  4.     {
  5.     if (document.addressline2.value != "") {document.getElementById('DIVaddressline2').style.display == 'block';
  6.     }
  7.  
  8. </script>
  9.  
then there is an onLoad event handler on the body tag:
Expand|Select|Wrap|Line Numbers
  1. <body onload="HideEmptyFields();">
  2.  
finally... in the PHP portion of the code, i have it written like this:

Expand|Select|Wrap|Line Numbers
  1. <div id="DIVaddressline2" style="display:none;"><?php echo $_POST["addressline2"] ; ?></div><br>
  2.  
is it not possible to hide a DIV with a <?php script inside?

thanks in advance.
Instead of functions, I tend to use more if statements, because to me functions are way too confusing to keep track of. And of course this won't work, I don't think you can embed PHP in Java, try it the other way around.
Feb 22 '07 #2
Motoma
3,237 Expert 2GB
Take a look at the raw HTML that comes from the PHP file (in your browser, view source). Does the HTML/XHTML look correct to you? Are there any syntactical errors?
Feb 22 '07 #3
chunk1978
224 100+
Take a look at the raw HTML that comes from the PHP file (in your browser, view source). Does the HTML/XHTML look correct to you? Are there any syntactical errors?
all seems fine to me (well, except for the fact that i don't see any PHP code in the view source for the .php file?)... anyway, i'm way new to PHP, and therefore it all looks good to me (eventhough it doesn't work) ;-)

any guidance would be greatly appreciated...
Feb 22 '07 #4
chunk1978
224 100+
Instead of functions, I tend to use more if statements, because to me functions are way too confusing to keep track of. And of course this won't work, I don't think you can embed PHP in Java, try it the other way around.
hey The1corrupted, thanks for the reply...

how would you write something like that the other way around? i'm very new to PHP...
Feb 22 '07 #5
Motoma
3,237 Expert 2GB
all seems fine to me (well, except for the fact that i don't see any PHP code in the view source for the .php file?)... anyway, i'm way new to PHP, and therefore it all looks good to me (eventhough it doesn't work) ;-)

any guidance would be greatly appreciated...
You need to understand how PHP works.
PHP is a program that generates HTML.
When it gets to your web-browser, it will be ENTIRELY HTML (and javascript if you include it).
To your web browser, this is no different then viewing a static HTML page (i.e. a file with a .html extension).
Feb 22 '07 #6
chunk1978
224 100+
You need to understand how PHP works.
PHP is a program that generates HTML.
When it gets to your web-browser, it will be ENTIRELY HTML (and javascript if you include it).
To your web browser, this is no different then viewing a static HTML page (i.e. a file with a .html extension).
hey motoma... thanks for telling me that, its a big help... makes things for me a little more clear...
Feb 22 '07 #7
Motoma
3,237 Expert 2GB
hey motoma... thanks for telling me that, its a big help... makes things for me a little more clear...
I hope so.
I consequence of this fact is that you can save the result of a PHP page as HTML, and tinker with it on your local machine until you find the bug in your HTML/Javascript.
Feb 22 '07 #8

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

Similar topics

5
by: Steve | last post by:
Visual Studio 2003 C# Windows: I have a tree view control as my main menu control down the left side of my application. This has 2 Parent Nodes on it (Jobs and Employees). beneath these 2 main...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
10
by: oLE | last post by:
I would like to add some javascript to show/hide a certain row of a table. The first row of the table contain the hyperlink that calls the javascript the second row is the one i want to show/hide...
5
by: jrefactors | last post by:
I am trying to debug some values in production server. I want to print the value of rRes(10), but I don't want to show it in the screen. I just want to show it in the source code but comment out,...
5
by: spielmann | last post by:
Hi How can we hide and show the taskbar without dll on vb.net? How can we set the scrollbar size without dll on vb.net?
2
by: jeet_sen | last post by:
Hi, I have created a table colelcting data from an XML source. After I built the whole table I ahve given user options to filter out columns from the table. For this I have collected all the...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
1
by: pamate | last post by:
hi, I want to show hide layers. I am able to show and hide layers but i am facing problem that, cant view the cursor in Mozilla,but i can type in input text box, its overlapping the layers. ...
1
by: ll | last post by:
I'm currently working on a form which consists of a show and hide javascript. The toggle works fine, although when I click on submit, I would like the page to reload with the toggle (show/hide)...
5
by: question.boy | last post by:
I am trying to control the visibility of a set of div based on selected values but can't seem to get it right. Below is what I have so far but it does not work at all. The basic concept was to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.