• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 825
  • Last Modified:

Checkbox and dropdown list in HTML Cell


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:
  • 4
  • 2
1 Solution
You could use ASP.NET. To do this with pure HTML and Javascripts (or VBScript) is possible.
DoofuSAuthor Commented:
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?
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

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

DoofuSAuthor Commented:

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.

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">
<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>

<form name="f">
<table border="1">
	<tr id="tr1" onDblClick="foco(1)">
		<input type="hidden" name="tr1_value" value="1">
		<div id="div1">Perez</div>
	<tr id="tr2" onDblClick="foco(2)">
		<input type="hidden" name="tr2_value" value="2">
		<div id="div2">Narvaez</div>
	<tr id="tr3" onDblClick="foco(3)">
		<input type="hidden" name="tr3_value" value="3">
		<div id="div3">Madrid</div>
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;

Open in new window

DoofuSAuthor Commented:
Thank you so much. I am looking in to it and will report.
DoofuSAuthor Commented:
Thanks wmadrid1 and my apologies for a delayed response!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get 10% Off Your First Squarespace Website

Ready to showcase your work, publish content or promote your business online? With Squarespace’s award-winning templates and 24/7 customer service, getting started is simple. Head to Squarespace.com and use offer code ‘EXPERTS’ to get 10% off your first purchase.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now