Solved

Checkbox and dropdown list in HTML Cell

Posted on 2010-08-26
7
794 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

737 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