Solved

Checkbox and dropdown list in HTML Cell

Posted on 2010-08-26
7
788 Views
Last Modified: 2012-05-10
Hi,

I'd like to know if I could design a data grid like this with preloaded values in the dropdown list
Here is what I'd like to develop:
http://linux.softpedia.com/screenshots/phpMyAdmin_2.png
0
Comment
Question by:DoofuS
  • 4
  • 2
7 Comments
 
LVL 1

Expert Comment

by:THBA
ID: 33536267
You could use ASP.NET. To do this with pure HTML and Javascripts (or VBScript) is possible.
0
 

Author Comment

by:DoofuS
ID: 33538571
cant use asp.net... first off, I am not at all versed.  I'm not sure if you wanted to say it is IMPOSSIBLE to do it in plain HTML?
0
 
LVL 5

Expert Comment

by:wmadrid1
ID: 33539884
hi,
It's totally possible, on phpmyadmin that's done on HTML + Javascript

finally .NET just help us with the javascript alredy incorpored on the controls.

In the past i developed something like it, i can pass you the code because it have copyright, but i can tell you how a did the part of the preloaded dropdown list

First i had a hidden div (divlist) which was filled with the data.
After the table with the data
Each row had his td columns, and in the dropdown list column, for each row, i had a div (divrow) just with the actual text and a hidden input with the value.

So when the row was clicked, a javascript function is called and on this,
the innerHTML of divrow is set with the divlist innerHTML, and the selectedIndex set to the value of hidden input.

This is the basic you ant to do, you must have in mind other things
such as when another row is clicked so then the prev row must save the data with AJAX and the divrow set again with the selected text


0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:DoofuS
ID: 33555141
wmadrid,

Can you please help me with a sample code? Like just for row of the table? I am very new to this but since you said it is possible to do it with HTML and Javascript, I would build on the sample code.
0
 
LVL 5

Accepted Solution

by:
wmadrid1 earned 500 total points
ID: 33555683
DoofuS,

The code below, just assign the listbox and assing the value of it for each table row
It was tested with Mozilla Firefox 3.6.8, with IE maybe need come little changes

That's a good begin
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
<div id="combo" style="display:none; ">
<select name="list">
	<option value="1">Perez</option>
	<option value="2">Narvaez</option>
	<option value="3">Madrid</option>
	<option value="4">Other</option>
</select>
</div>

<form name="f">
<table border="1">
	<tr id="tr1" onDblClick="foco(1)">
		<td>
		Juan
		</td>
		<td>
		<input type="hidden" name="tr1_value" value="1">
		<div id="div1">Perez</div>
		</td>
	</tr>
	<tr id="tr2" onDblClick="foco(2)">
		<td>
		Jose
		</td>
		<td>
		<input type="hidden" name="tr2_value" value="2">
		<div id="div2">Narvaez</div>
		</td>
	</tr>
	<tr id="tr3" onDblClick="foco(3)">
		<td>
		Adrian
		</td>
		<td>
		<input type="hidden" name="tr3_value" value="3">
		<div id="div3">Madrid</div>
		</td>
	</tr>
</table>
</form>
<script>
function foco(id)
{
	var divC = document.getElementById("combo");
	var div = document.getElementById("div"+id);
	div.innerHTML = divC.innerHTML;
	var value = document.f.elements["tr"+id+"_value"].value;
	//Assing the value of listbox to the hidden value
	//This can change with IE
	div.childNodes[1].value = value;
}
</script>
</body>
</html>

Open in new window

0
 

Author Comment

by:DoofuS
ID: 33558591
Thank you so much. I am looking in to it and will report.
0
 

Author Closing Comment

by:DoofuS
ID: 33656591
Thanks wmadrid1 and my apologies for a delayed response!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Someone recently asked me about how to display a progress indicator on a page while an iframe is loading. And I remember when I first came across this myself. It was a bit tricky to get my head around, but really, it's very simple. The most impor…
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

786 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