Connecting Tech Pros Worldwide Help | Site Map

Arrays on mouseover displayed in tooltip?

marcbinaus@hotmail.com
Guest
 
Posts: n/a
#1: Nov 3 '05
Hi,

I have 3 textboxes A B C
The user can only enter single digit numbers in the textboxes, and if
they hover over a blank textbox it would give them the options through
a tooltip of what numbers are left over.
For instance if A =1, tooltip over B & C would = "2,3,4,5,6,7,8,9"
and B = 4, tooltip over C= "2,3,5,6,7,8,9"

I worked out a solution in vb, but that needs page postbacks, and I
would like to move away from that and make it smoother

So, how do I:
Write an array in javascript and calculate what is misssing if the
mouse hovers over a blank textbox and transfer whats missing to a
tooltip?


I suppose it would share the same logic of a sodoku puzzle thinking
about it, but sadly its not as exciting as that.

Randy Webb
Guest
 
Posts: n/a
#2: Nov 3 '05

re: Arrays on mouseover displayed in tooltip?


marcbinaus@hotmail.com said the following on 11/3/2005 6:28 AM:
[color=blue]
> Hi,
>
> I have 3 textboxes A B C
> The user can only enter single digit numbers in the textboxes, and if
> they hover over a blank textbox it would give them the options through
> a tooltip of what numbers are left over.[/color]

hover over the textbox? Use the onFocus to make it show, the onBlur to
make it go away.
[color=blue]
> For instance if A =1, tooltip over B & C would = "2,3,4,5,6,7,8,9"
> and B = 4, tooltip over C= "2,3,5,6,7,8,9"[/color]

onFocus="showTooltip(this)"

function showTooltip(elem){
var a = elem.form.elements['textbox1'].value;
var b = elem.form.elements['textbox2'].value;
var c = elem.form.elements['textbox3'].value;
var masterString = "0123456789";
var notUsed = masterString.replace(a,'').replace(b,'').replace(c ,'');
var notUsedArray = notUsed.split()
alert(notUsedArray)
//use the reference to elem to know where/which tooltip to display
//the results of notUsed
}
[color=blue]
> I worked out a solution in vb, but that needs page postbacks, and I
> would like to move away from that and make it smoother
> So, how do I:
> Write an array in javascript and calculate what is misssing if the
> mouse hovers over a blank textbox and transfer whats missing to a
> tooltip?[/color]

Use a simple string, replace what is used so far with blank space, then
split it to get an Array.
[color=blue]
> I suppose it would share the same logic of a sodoku puzzle thinking
> about it, but sadly its not as exciting as that.[/color]

What is a sodoku puzzle?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
David Wahler
Guest
 
Posts: n/a
#3: Nov 3 '05

re: Arrays on mouseover displayed in tooltip?


Randy Webb wrote:[color=blue]
> marcbinaus@hotmail.com said the following on 11/3/2005 6:28 AM:[color=green]
> > I suppose it would share the same logic of a sodoku puzzle thinking
> > about it, but sadly its not as exciting as that.[/color]
>
> What is a sodoku puzzle?[/color]

http://en.wikipedia.org/wiki/Sudoku :)

-- David

marcbinaus@hotmail.com
Guest
 
Posts: n/a
#4: Nov 4 '05

re: Arrays on mouseover displayed in tooltip?


Thanks for the answer, I have used your code and the following code:
<script type="text/javascript">

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library
(www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source
code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] :
document.getElementById? document.getElementById("dhtmltooltip") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")?
document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){


if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="")
tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var rightedge=ie&&!window.opera?
ietruebody().clientWidth-event.clientX-offsetxpoint :
window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera?
ietruebody().clientHeight-event.clientY-offsetypoint :
window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of
the context menu
if (rightedge<tipobj.offsetWidth)
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=ie?
ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" :
window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
else if (curX<leftedge)
tipobj.style.left="5px"
else
//position the horizontal position of the menu where the mouse is
positioned
tipobj.style.left=curX+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie?
ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px"
: window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

</script>

and written this in the pageload
C.Attributes.Add("onMouseover", "ddrivetip(showTooltip(C,'yellow',
300)")

and it works great apart from I can't transfer the notUsedArray to
appear in the textbody.
Can you help?

Closed Thread