Solved

Checkbox and dropdown list in HTML Cell

Posted on 2010-08-26
7
792 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

821 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