Solved

Grey out an entire table row - php/javascript

Posted on 2013-05-13
7
1,119 Views
Last Modified: 2013-06-13
Hi,
I have a php page where I query the database and generate a table to display the results. Now in the table, on clicking an element I want to grey out that row.
code snippet for the table
echo "<table><tr>
                                        <th>Exclude</th>
&#9;&#9;&#9;&#9;&#9;<th>Hospital</th>
&#9;&#9;&#9;&#9;&#9;<th>Patient</th>
&#9;&#9;&#9;&#9;&#9;<th>NS</th>
&#9;&#9;&#9;&#9;&#9;<th>MRN</th>
&#9;&#9;&#9;&#9;</tr>";
<?

for($i=0; $i < 10; $i++){
?>
            <tr>
              <th align="left" class="form-matrix-row-headers" nowrap="nowrap">
                <? echo $i+1;?>
              </th>
              <td align="center" class="form-matrix-values">
                <input class="form-textbox" type="text" size="5" name="qt6_clickPatient[<? echo $i;?>][]" />
              </td>
              <td align="center" class="form-matrix-values">
                <input class="form-textbox" type="text" size="5" value = <? echo $census_report[$i]["Bed"];?> name="qt6_clickPatient[<? echo $i;?>][]" />
              </td>
              <td align="center" class="form-matrix-values">
                <input class="form-textbox" type="text" size="5" value = <? echo $census_report[$i]["Patient"];?> name="qt6_clickPatient[<? echo $i;?>][]" />
              </td>
<?
}
?>

Open in new window


Now if I click on patient name both bed and patient name should be greyed out, indicating that this record has been disabled for further processing, and a check mark appear under exclude.
Appreciate any help.
I have a javascript which fires up on onChange event
     document.getElementById("Patient").disabled = true;
But this does not work as the records are inside a for loop and in an array.
Thanks,
0
Comment
Question by:Mohit_t
  • 3
  • 3
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39163556
0
 

Author Comment

by:Mohit_t
ID: 39186243
Hi leakim971,
Thanks for the quick response. I was caught up in other development activities so could not reply earlier. I implemented your solution, this works fine in IE but not in FF or Chrome. Appreciate if you can help me make it cross-browser compatible.
Also I need to be able to toggle i.e. once greyed out I also need to re-enable the cells by clicking on the table row, this was not there in my original post.

Thanks,
0
 

Author Comment

by:Mohit_t
ID: 39205126
Appreciate any comments / solutions/ inputs on this question
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 82

Expert Comment

by:leakim971
ID: 39206028
the solution work fine for me on FF and Chrome
0
 

Author Comment

by:Mohit_t
ID: 39206762
Hi  leakim971,
In IE 9 the solution works correctly I choose some table rows and they are greyed out and on submission of the form, I don't see the greyed out records on the next page.
In Chrome 27.0.x, table rows are greyed but on form submission, I see the greyed out results also on the next page.
In FF 21.0 nothing happens on clicking the table rows.
Seems like both FF and chrome behave differently to the same code, there  might be some browser specific adjustments that need to be made.
Also how can we make this toggle between greying out the table rows and deselecting the greyed out rows when it is clicked again.
Could there be a solution for this in jquery, I have not used jquery very much so not sure of a solutio in jquery.
 
Thanks
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39207326
I don't see the greyed out records on the next page
Why do you think you will see them greyed on the next page?

In FF 21.0 nothing happens on clicking the table rows.
Not mine :
on FF 21
Look like we're not working on the same code? You should confirm the jsfiddle work for you first between integrating the code in your webpage and saying it don't work but perhaps I miss something?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now