473,385 Members | 1,919 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,385 software developers and data experts.

Dynamically enabling / disabling a row's elements using PHP

Hi,

I have just started coding in PHP. I have coded a web page using HTML, JS, and PHP. An HTML table has to be populated dynamically using the data from the backend.

Presently I have 5 records in the backend table so I get 5 HTML-table rows. I have created a session object starting from the login page. The requirement is that as soon as I log in and my request gets forwarded to the foll PHP page I should be seeing the foll. dynamically generated table. This portion has been done.

The next part is that the very first time my request gets forwarded to the foll PHP page, only the first row's [i.e. Job Attribute Hierarchy (see pic)] Go-button and textbox should be enabled, the remaining rows' textboxes and buttons should be disabled.

When I enter the data in the first row's textbox and hit 'Go'.. I come to another PHP page where in I fill some more data and hit 'OK' thereby coming back to the foll. PHP page. At this time the first row should have its textbox and Go-buttons disabled and there should be a tickmark on the first cell of the row. At this time only the second row's textbox and Go-button should be enabled and 1,3,4,5 row's elements should be disabled. Again the same procedure repeats... I hit the Go button on second row [Job Rewards/Culture Hierarchy (see pic)].. and my request gets forwarded to some other page where I hit OK and come back to the foll PHP page. This time there is a tickmark on the second row's first cell and it's textbox and Go-button are disabled alongwith those of row's 1,2,4,5 and only row 3's elements are enabled... and so on..

I believe I should be setting a flag variable as a session attribute to achieve this, but I am not getting a clear idea as to how I should use this flag to dynamically enable-disable the textboxes and Go-buttons. Any suggestions?

Regards,
sasha

[PHP]
<?php
session_start();

$flag = 0;

if(!isset ($_SESSION['flag']))
{
$flag = 1;
$_SESSION['flag'] = $flag;
}
else
{
$flag++ ;
$_SESSION['flag'] = $flag;
}

?>
<html>
<body>
<table align = "center" id = "TID" border = "1" cellpadding = "3" cellspacing = "3">
<?php
$selectMasterAttributes = "select * from MasterAttributes ;" ; // select all columns(Name,NameId,Active)
$selectMasterAttributes_result = mysql_query($selectMasterAttributes) or die("Error with $selectMasterAttributes ");

if(mysql_num_rows($selectMasterAttributes_result) > 0)// proceed with the dynamic attribute-row-creation only if backend attribute table contains any attributes
{

while($row = mysql_fetch_array($selectMasterAttributes_result))
{
$MAttrName = $row['Name'];
//echo $MAttrName . '<br>' ;
$MAttrNameId = $row['NameId'];
//echo $MAttrNameId . '<br>';
$MAttrActive = $row['Active'];
//echo $MAttrActive . '<br>' ;

echo '<tr id = "' . $MAttrNameId . '">';
echo '<td bgcolor = "orange">' . $MAttrNameId . '</td>';
echo '<td>' . $MAttrName . '</td>';
echo '<td ><input type = "text" size = "5" id = "Attr'. $MAttrNameId .'" name = "Attr'. $MAttrNameId .'"></td>';
echo '<td><input type = "submit" name = "go' . $MAttrNameId . '" value = "Go" onclick = "set_attr_name(this.name)"></input></td>';
echo '</tr>';

}

}// (mysql_num_rows($selectMasterAttributes_result) > 0) over
else
{
echo '<tr><td colspan = "4"> No Attributes Present in backend</td></tr>' ;
}

?>
</table>
</body>
</html>
[/PHP]
Attached Files
File Type: zip pic.zip (42.8 KB, 198 views)
Dec 13 '07 #1
1 5168
Hi again,

The problem is resolved now, thanks anyway.

Regards,
Sasha
Dec 13 '07 #2

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

Similar topics

4
by: Terry | last post by:
I have a number of input boxes used to display totals based on selected items for each row in a table. There are more than a few rows that are identical, except for the form field name. I have...
1
by: Peter Kirk | last post by:
Hi there I have a form which submits a list of data to a web-application (which then saves to a database). The list consists of four input fields per row. Eg....
8
by: cool2005 | last post by:
I tried to dynamically add/clone a <tr> from an existing <tr> to a <table> but the problem is that I need to have a "onclick" event handler in the <tr>. I have tried following A. approach...
2
by: HumptyDumpty | last post by:
Does anyone know if there is a problem with re-enabling the Screen Saver after it has been disabled programmatically. I am using the SystemParametersInfo function within User32.dll, and have...
5
by: misiek | last post by:
Hi all. I would like to know if it is possible to dynamically enable/disable row editing in GridView control in ASP.NET 2.0. I am asking because this feature should be enabled/disable depending...
2
by: dougawells | last post by:
Hi- I'm wanting to have a set of radio buttons disabled when a form is displayed, then if they check another specific radio button, those would become enabled. I've tried setting it via...
7
by: Steve_Black | last post by:
Hello, I'm toying with the idea of loading a MenuStrip (VB.Net 2005) dynamically based on who is logged into my system. Every user has different security settings and I want to customize the...
4
by: somaskarthic | last post by:
Hi I posted query about dynamically generating php code. Sorry for the inconvenience . I didn't given you the php code. Its just javascript code which dynamically create rows on button click event....
2
by: aric.bills | last post by:
Hello all, I'm a novice Javascript programmer, and I'm having browser compatability issues regarding dynamic generation of tables. The following content generates "hello" in Firefox 1.5, but...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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,...
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...

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.