473,799 Members | 3,026 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to show table based on variable?

I want to display a table on a page based on whether a button is
pressed or not. I'm new at php so I'm sure I'm making a basic
mistake. Here's what I am trying. My thought was that $show_summary
would switch states with each click but it is coming up always true.
So I'm guessing that is the default setting when the page loads. Can
someone please point out where I am going wrong?

if(isset($_POST['summary'])) {
$show_summary = true;
} else {
$show_summary = false;
}

<FORM method="POST" action="testpag e.php">
<INPUT type="submit" name="summary" value="Show Summary">
</FORM>

<?php if ($show_summary == true) { ?>
<table border="1" cellpadding="3" >
<tr>
<td class="smallTex t" align="center" width="80%"><?p hp echo "URL";
?></td>
</tr>
</table>
<?php } ?>

Jack
Jul 17 '05
11 2318
Moxley Stratton <mo****@REMOVEm oxleydata.com> wrote in message news:<W9******* *************@c omcast.com>...
Jack wrote:
Pedro Graca <he****@hotpop. com> wrote in message news:<2h******* *****@uni-berlin.de>...
Jack wrote:

Pedro Graca <he****@hotpop. com> wrote in message news:<2h******* *****@uni-berlin.de>...

>Jack wrote:
>
>>I want to display a table on a page based on whether a button is
>>pressed or not.
>
>If the button is not pressed, how does PHP receive the data?
Thanks for the help. This does work. I'll look into your suggestion
about javascript too since I would really rather have just the one
button.

I still don't understand how you're going to submit a form without
pressing a button :-)

I'm not really wanting to submit a form. That was the only way I
could think of to try to do what I wanted. All I want is a button
that acts as an on/off switch. Press it once and a table is
displayed. Press it again and the table is hidden.

If you don't mind using javascript and css:

<script type="text/javascript">
var visibility = 'hidden';
function toggleTable()
{
if( visibility == 'visible' ) visibility = 'hidden';
else visibility = 'visible';

document.getEle mentById('myTab le').style.cssT ext =
'visibility: ' + visibility;
}
</script>

<table id="myTable" style="visibili ty: hidden">
<tr><th>My Table</th></tr>
</table>

<input type="button" onclick="toggle Table()" value="table">


Thanks for the code - this works great. My thanks to all those that
helped. This was quite a learning experience.

Jack
Jul 17 '05 #11
<snip>
I want to display a table on a page based on whether a button is
pressed or not.


You don't mention what the data of the table you are referring to, And
this is probably off track Or at least the subject of another news
group, BUT, perhaps you could do it w/o hitting the server again:
<table id="dam" border="1">
<tr><td> The dam Table.</tr></td>
</table>

<a href="#" onClick="docume nt.getElementBy Id('dam').style .visibility='vi sible'">Show
the dam table</a>

<button onClick="docume nt.getElementBy Id('dam').style .visibility='hi dden'">Hide
the dam table</button>

Of course I'm sure it brings up a whole new slew of compatibility
issues you would have to consider.
Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1796
by: Anne M | last post by:
I have a report based on query..which is a team list with names and their role on team ie coach, assistant and player. Report is almost what I want and my knowledge is limited so I need some advice. I want the team list to show the names of the individuals and their role on team if they are coach or assistant but not if they are player but since they are based on the same field (role) how do I set it so I can get it to show only what...
3
2610
by: Lynn | last post by:
Hello, I have a user control that contains a table, and some text fields. I would like to show or hide a particular row of this table, based on a selection the user makes on my page. Here's the situation...I have a page that has some panels that are hidden. The first panel is visible...the user selects a city, and presses submit. The next panel is made visible, and in this panel I have placed a user
2
2724
by: Steve Bottoms | last post by:
Hi, all! Using VB as code-behind in asp.net page... I have a TABLE control which I'm building dynamically. After the table is built, I'm trying to retrieve the HEIGHT property of that table (table.height.value) to be able to dynamically position the next elements on the form. However, this control property is coming back as -0- every time. I also try to get the table height with Javascript after-the-fact (table.style.height), but that...
4
1394
by: robmarleh | last post by:
Hi, I've been trying to set up a php system to calculate and order and recieve delivery address/s. It's going pretty well so far but I having trouble with one particular part. I've been trying to use a for loop to show a number of delivery address forms based on the quantity of the product ordered, (sounds like a strange thing to do but the product is intended for people so send to friends as a novelty item) I have created a php file of...
9
3065
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped. Below you will find the code I've written and the error that results. I'm hoping that someone can give me some direction as to what syntax or parameter is missing from the code that is expected by VBA. Overview: I'm trying to copy calculated...
2
3896
by: banderson | last post by:
Hello, I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg mgmt company names and then to open a building management company form to show all records with this name, so the user can find the correct branch location to select. Then, upon closing the building management company form, the active/selected record...
5
4476
by: Mike P | last post by:
How would I show or hide a div that is using client side Javascript based upon a server side variable? Here are my divs : <div id="idButton5" class="otherLeftBarLink" onmouseover="javascript: changeStylesMouseOver('5');" onmouseout="javascript: changeStylesMouseOut('5');" onclick="location='/AddProject.aspx'"> <div class="leftBarLinkText"> Add Project
1
1632
by: filch | last post by:
Hi, I am new to this forum ... so hello to all! I am trying to get a script working which will show or hide a table based on a user checking or unchecking a parent checkbox. This is the script I have come up with so far (note that one of my issues is whether or not you can use an if/else construct inside of a case statement): function showIt($id) { alert("ID is : $id"); switch ($id) {
1
3814
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown properties alt in img tag istead of picture . place of the pictures is saved in the database(my database is with mysql) and in home page i fetch properties of the product and address of place that pictures is located output of the code in the...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10491
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
10268
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...
1
10247
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 most users, this new feature is actually very convenient. If you want to control the update process,...
1
7571
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
6809
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
5467
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4146
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
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.