Solved

Checkbox and dropdown list in HTML Cell

Posted on 2010-08-26
7
782 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Column Spacing 3 34
Mobile menu navigation , its html and css 6 36
.Net Web Site Password specs 2 20
Bootstrap 3 icons 3 10
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Do you want to insert HTML5 video into your site? This is the tutorial how to do so. What are the main advantages of HTML5 video? 1) Have good compression, good image quality, and low decode processor use. 2) It is royalty-free 3) It is easi…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…

707 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

12 Experts available now in Live!

Get 1:1 Help Now