473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

textbox and div

could someone please point me to a site with an explanation or give me a
*very* simple example of a div that would open right below a textbox on a
page. I've seen lots of examples out there. Unfortunately I don't have time
right now to dig through that code to extract the basic functionality. The
one implementation that really hits the spot can be found here:

http://www.eworldui.net/CustomContro...PopupDemo.aspx

look at the "Calendar Popup with Textbox and Image:"

thank you so much in advance!!


Jul 23 '05 #1
10 3532
Alex wrote:
could someone please point me to a site with an explanation or give me a
*very* simple example of a div that would open right below a textbox on a
page. I've seen lots of examples out there. Unfortunately I don't have time
right now to dig through that code to extract the basic functionality. The
one implementation that really hits the spot can be found here:


I like this one:

http://www.softcomplex.com/products/...dar/demo1.html

The download has nice example code:

http://www.softcomplex.com/products/.../download.html

Mike
Jul 23 '05 #2
Thanks, Mike, for the reply! The problem with the tigra implementation is
that it pops up an actual browser window and not a div. also, I don't really
need it for a calendar right now just to display some additional information
about the textbox the user just clicked on... does that make sense?

Here's a mind-numbingly simple example that I need to be converted to the
point where the divs (when shown) will not push other content down but
"float" right below the textbox... I guess the style has to change to
position:absolute... but how can I grab the coordinates to put the div in??

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My cool div pop-out</title>
</head>

<body>
<form>
<table border=1>
<tr>
<td>some field here</td>
<td><input type="text" id="thisText"
onClick="javascript:document.all.divOne.style.disp lay=''"><div id="divOne"
style="display:none;position:relative;border:1px
solid;width:200px;height:150px"></div></td>
</tr>
<tr>
<td>some field there</td>
<td><input type="text" id="thisText"
onClick="javascript:document.all.divTwo.style.disp lay=''"><div id="divTwo"
style="display:none;position:relative;border:1px
solid;width:200px;height:150px"></div></td>
</tr>
</table>
</form>
</body>
</html>

"mscir" <ms***@yahoo.com> wrote in message
news:11*************@corp.supernews.com...
Alex wrote:
could someone please point me to a site with an explanation or give me a
*very* simple example of a div that would open right below a textbox on a
page. I've seen lots of examples out there. Unfortunately I don't have
time
right now to dig through that code to extract the basic functionality.
The
one implementation that really hits the spot can be found here:


I like this one:

http://www.softcomplex.com/products/...dar/demo1.html

The download has nice example code:

http://www.softcomplex.com/products/.../download.html

Mike

Jul 23 '05 #3
Alex,
Thanks, Mike, for the reply! The problem with the tigra implementation is
that it pops up an actual browser window and not a div. also, I don't really
need it for a calendar right now just to display some additional information
about the textbox the user just clicked on... does that make sense?


Sorry I didn't read it correctly. What do you think of using hovertext?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title>Pure css tooltips by santaklauss</title>

<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">

<meta name="generator" content="HAPedit 3.0">

<style type="text/css">
body { width: 100%; text-align: left; }
div#main {margin: 0 25%}
p {line-height: 150%}
a.info {
position: relative;
z-index:24;
background-color:#cccccc;
color:#000000;
text-decoration:none;
}
a.info:hover {z-index:25;background-color: #ff0}
a.info span {display: none}
a.info:hover span {
display:block;
position:absolute;
top:2em;
left:2em;
width:15em;
border:1px solid #0cf;
background-color:yellow;
color:red;
font-size: 1.1em;
font-weight: bold;
text-align: center
}
</style>
</head>

<body>

<div id="main">

<h3>Example code using your image:</h3>

<hr>

1939 September 2 - When Germany attacked Poland, the day was marked by
raids of the German aviation on the city and fortress of Brzesc nad Bugiem
(the city's name at that period), which caused human losses and damaged
buildings in the city and in the fortress.
<p>
<a class="info" href="#">Move the Mouse over this Text Box
<input type="text">
<span>This text only appears in the popup when you move the mouse
over the image.</span>
</a>
</p>
<p>
<a class="info" href="#">Move the Mouse over this Text Box
<input type="text">
<span>This text also appears ONLY when the mouse moves over the
image.</span>
</a>
</p>
</div>
</body>
</html>
Jul 23 '05 #4
Alex wrote:
Thanks, Mike, for the reply! The problem with the tigra implementation is
that it pops up an actual browser window and not a div. also, I don't really
need it for a calendar right now just to display some additional information
about the textbox the user just clicked on... does that make sense?


If you are considering tooltips, these are pretty nice:

http://www.dyn-web.com/dhtml/tooltips/

Mike
Jul 23 '05 #5
Alex wrote:
Thanks, Mike, for the reply! The problem with the tigra implementation is
that it pops up an actual browser window and not a div. also, I don't really
need it for a calendar right now just to display some additional information
about the textbox the user just clicked on... does that make sense?


Will something like this work?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My cool div pop-out</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<style type="text/css">
div.tooltip{
width: 100%;
border: 0;
padding: 0;
margin: 0;
}
table{
border: 1px;
padding: 0;
}
</style>
<script type="text/javascript">
var msg= new Array(2);
msg[0]='This is the first<br>explanation';
msg[1]='This is the second<br>explanation';
function showmsg(n){
d=document.getElementById('tooltip');
if (n==-1){
d.innerHTML='';
}else{
d.innerHTML=msg[n];
}
}
</script>
</head>

<body>
<form action="#">
<table border=1>
<tr>
<td>some field here</td>
<td><input type="text" onMouseMove="showmsg(0)"
onmouseout="showmsg(-1)"></td>
<td rowspan="2"><div id='tooltip'></div></td>
</tr>
<tr>
<td>some field there</td>
<td><input type="text" onMouseMove="showmsg(1)"
onmouseout="showmsg(-1)"></td>
</tr>
</table>
</form>
</body>
</html>
Jul 23 '05 #6
I actually have to put some information in html form in that div. since it
doesn't really matter for the sake of this exercise I left it out. I guess I
should have mentioned it... sorry.

the closest I have come to my needs is this:
http://www.dyn-web.com/dhtml/write-drag/img-txt.html

here are some pieces that I still need to consider:

1. four js include files sounds like a bit much for my needs.
2. I have to turn the whole thing into a C#.NET control: the less js to
maintain the better. but then again, includes are ok
3. Dragging is a cool feature but not needed in my case. for that,
ferant.com is ideal!
4. I'll have to find the top-offsets for the height of the <input
type="text">... how to do that?
5. need to find a solution for the <select> z-index problem
6. div needs to close automatically
7. etc. etc. etc.

I guess, nothing earth shattering... but hovertext certainly won't work. And
I'm sure I'm missing a few things....

Well... I've been playing around a bit more and this is what I've come up
with... rather crude but you get the idea -- excuse the colors... ;)

<CODE>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My cool div pop-out</title>
<style>
</style>
</head>

<body>
<form>
<table border=1>
<tr>
<td>some field here</td>
<td><a id="aText"/><input class="txt" value="click here - dead!"
type="text" xstyle="height:40px"></td>
</tr>
<tr>
<td>some field here</td>
<td><a id="aText"/><input class="txt" value="tab here from prev. textbox,
don't click! use dwn-arrow" type="text" style="width:400px" id="thisText"
onKeyUp="tryKey(this, divOne)" onClick="openit(this, divOne)"><div
onClick="closeit(this)" id="divOne"
style="background-color:#ffcc33;display:none;position:relative;borde r:1px
solid;width:200px;height:150px;overflow:auto">clic k on me to close... or hit
[Esc]<br><br><br><br><br><br><br><br><br><br><br><br><b r><br><br><br><br><br><br><br><br><br><br><br><br> <br><br><br></div></td>
</tr>
<tr>
<td>some field there</td>
<td><input type="text" id="thisText" value="click here to open"
onClick="openit(this, divTwo)"><div onClick="closeit(this)" id="divTwo"
style="background-color:#ffcc33;display:none;position:relative;borde r:1px
solid;width:200px;height:150px">click on me to close</div></td>
</tr>
<tr>
<td>some field there</td>
<td><select name="bother"><option>one<option>two<option>three</select></td>
</tr>
</table>
</form>
</body>
</html>
<script language="JavaScript">
function tryKey(t, d){
var e = event.keyCode;
//alert(typeof(e) + ': ' + e);
if(e == 40){
openit(t, d);
}
else if(e == 27){
closeit(d);
}
}

function openit(t, d){

var x = findX(t);
var y = findY(t);

d.style.display=''
d.style.position='absolute';
d.style.top = y+20; //<<< needs to be determined programmatically!
d.style.left = x;

t.focus();

}

function closeit(o){
o.style.display='none';
}

function findX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft;
obj = obj.offsetParent;
}
}
else if (obj.x) {
curleft += obj.x;
}
return curleft;
}
function findY(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop;
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
</script>
</CODE>
Jul 23 '05 #7
<snip>

How about an absolutely positioned div? You can track the mouse and make
it appear next to the mouse, or use a simpler approach: hard code it as
I did here. Lots less javascript with this approach: A div appears with
the correct message, then disappears after 2 seconds.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>
<head>
<title>Div Tooltips</title>
<script type="text/javascript">
var msg=new Array(5);
msg[1]='This is the first message to appear in the message div';
msg[2]='This is the second message to appear in the message div';
msg[3]='This is the third message to appear in the message div';
msg[4]='This is the fourth message to appear in the message div';
msg[5]='This is the fifth message to appear in the message div';
function init(){
msgdiv=document.getElementById('messagediv');
}
function showdiv(theId) {
hidemsgdiv();
msgdiv.innerHTML=msg[theId];
msgdiv.style.visibility = "visible";
// set timeout to hide div in 2 seconds
var tid = setTimeout("hidemsgdiv()", 2000);
}
function hidemsgdiv() {
msgdiv.style.visibility = "hidden";
}
</script>
<style type="text/css">
..text{
font-size: 90%;
}
..hidden{
visibility: hidden;
border: 1px solid green;
color: red;
background-color: #FFFFFF;
padding: 1px;
position: absolute;
width: 200px;
height: 200px;
top: 10px;
left: 260px;
}
</style>
</head>

<body onload='init()'>
<p>
Text1 Div1&nbsp;<input type="text" onMouseOver="showdiv(1)"><br>
Text2 Div2&nbsp;<input type="text" onMouseOver="showdiv(2)"><br>
Text3 Div3&nbsp;<input type="text" onMouseOver="showdiv(3)"><br>
Text4 Div4&nbsp;<input type="text" onMouseOver="showdiv(4)"><br>
Text5 Div5&nbsp;<input type="text" onMouseOver="showdiv(5)"><br>
</p>
<div class='hidden' id='messagediv'></div>
</body>
</html>
Jul 23 '05 #8
Those are two great examples. The fact that they are very concise is awsome!
The only *one* problem now remains that they will have to stay open as long
as focus is in the textbox OR they are doing something in the div -- like
selecting a value to be put in the textbox. Once they tab off the field,
click somewhere in the body of the page or just onMouseOut off the div the
div should "close". Thanks so much!!

"mscir" <ms***@yahoo.com> wrote in message
news:11*************@corp.supernews.com...
Alex wrote:
Thanks, Mike, for the reply! The problem with the tigra implementation is
that it pops up an actual browser window and not a div. also, I don't
really need it for a calendar right now just to display some additional
information about the textbox the user just clicked on... does that make
sense?


Will something like this work?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>My cool div pop-out</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<style type="text/css">
div.tooltip{
width: 100%;
border: 0;
padding: 0;
margin: 0;
}
table{
border: 1px;
padding: 0;
}
</style>
<script type="text/javascript">
var msg= new Array(2);
msg[0]='This is the first<br>explanation';
msg[1]='This is the second<br>explanation';
function showmsg(n){
d=document.getElementById('tooltip');
if (n==-1){
d.innerHTML='';
}else{
d.innerHTML=msg[n];
}
}
</script>
</head>

<body>
<form action="#">
<table border=1>
<tr>
<td>some field here</td>
<td><input type="text" onMouseMove="showmsg(0)"
onmouseout="showmsg(-1)"></td>
<td rowspan="2"><div id='tooltip'></div></td>
</tr>
<tr>
<td>some field there</td>
<td><input type="text" onMouseMove="showmsg(1)"
onmouseout="showmsg(-1)"></td>
</tr>
</table>
</form>
</body>
</html>

Jul 23 '05 #9
In article <11*************@corp.supernews.com>,
mscir <ms***@yahoo.com> wrote:
var msg=new Array(5);
msg[1]='This is the first message to appear in the message div';
msg[2]='This is the second message to appear in the message div';
msg[3]='This is the third message to appear in the message div';
msg[4]='This is the fourth message to appear in the message div';
msg[5]='This is the fifth message to appear in the message div';


A minor point or two.

Javascript arrays are zero based so new Array(5) says you will be using
array elements 0, 1, 2 3, and 4. Declaring how many elements you will
use is somewhat redundant because Javascript sizes the array dynamically.

I like to declare arrays as such:

var msg= [ ];

Although in this instance, I like the direct assignment
of the array values, you could also do this:

var msg= [
/* 0 */ '',
/* 1 */ 'This is the first message to appear in the message div',
/* 2 */ 'This is the second message to appear in the message div',
/* 3 */ 'This is the third message to appear in the message div',
/* 4 */ 'This is the fourth message to appear in the message div',
/* 5 */ 'This is the fifth message to appear in the message div'
]

I thought the program was will written. I hope you find this suggestion
useful.

Robert
Jul 23 '05 #10
"Alex" <al******************@remove.this> wrote in message
news:0R******************@twister.rdc-kc.rr.com...
Those are two great examples. The fact that they are very concise is awsome! The only *one* problem now remains that they will have to stay open as long as focus is in the textbox OR they are doing something in the div -- like
selecting a value to be put in the textbox. Once they tab off the field,
click somewhere in the body of the page or just onMouseOut off the div the
div should "close". Thanks so much!!

Here's a variation of mscir's that does what you want.

The "tooltip" is on the sameline as the text box.

<html>
<head>
<title>My cool div pop-out</title>
<style type="text/css">
div.tooltip {
width: 100%;
border: 0;
padding: 0;
margin: 0;
}
table {
border: 1px;
padding: 0;
}
</style>
<script type="text/javascript">
var msg = new Array();
msg[1] = "This is the 1st explanation";
msg[2] = "This is the 2nd explanation";
function showmsg(n) {
var i = Math.abs(n);
var d = document.getElementById('tooltip'+i);
if (n < 0) {
d.innerHTML = "";
} else {
d.innerHTML = msg[n];
}
}
</script>
</head>
<body>
<form action="#">
<table>
<tr>
<td>some field here</td>
<td><input type="text" onfocus="showmsg(1)" onblur="showmsg(-1)"></td>
<td><div id='tooltip1'></div></td>
</tr>
<tr>
<td>some field there</td>
<td><input type="text" onfocus="showmsg(2)" onblur="showmsg(-2)"></td>
<td><div id='tooltip2'></div></td>
</tr>
</table>
</form>
</body>
</html>
Jul 23 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jonas L | last post by:
Hi, I need to create a textbox which acts as a normal textbox but with the following extra requirements: 1) In-focus color, when the textbox gets focus the backcolor property of the textbox...
4
by: Rodrigo DeJuana | last post by:
Howdy, I'm new to this .net stuff and really have little to no training. Im trying to create a new page for a web form, so i have been pretty much jsut coping code. I having some issue with...
0
by: Newasps | last post by:
Hi guys, I have a problem with UpdateCommand Event. In tihs event Ä°'m creating required controls to get that controls' values and also get them. But when I try to get updated values I'm getting the...
7
by: I am Sam | last post by:
I have a DataGrid that is passing information to a stored procedure properly but the parameters aren't being casted properly. I was woundering if anyone can tell me how I should properly cast the...
11
by: Keith | last post by:
I apologize for those of you who think I'm posting on the same topic. It is not that I don't appreciate all of your comments - and I'm definitely reading them all - but I think I have a differing...
2
by: Mamatha | last post by:
Hi I want to add an icon to the textbox's text. I don't know how to display icon in textbox in VB.NET. If any one knows please let me know. Thanks in advance. Mamatha
3
by: Brad Rogers | last post by:
All, Being immersed in vb.net and trying CSharp after almost a year I forgot the differences. I like vb fixing the uppercase/lowercase names and seeming to be more flexible to code entry. ...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
8
by: Marco Pais | last post by:
Hi there. How can I change the background color of a textbox when it gets the focus? I can handle the "Enter" event and do this private void txtDummie_Enter(object sender, EventArgs e) { ...
1
by: Andy B | last post by:
I have this code: protected void EditEventsWizard_NextButtonClick(object sender, WizardNavigationEventArgs e) { //get the values from the DetailsView TextBox StartTime =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.