Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Arrays on mouseover displayed in tooltip?

Reply
Thread Tools

Arrays on mouseover displayed in tooltip?

 
 
marcbinaus@hotmail.com
Guest
Posts: n/a
 
      11-03-2005
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.

 
Reply With Quote
 
 
 
 
Randy Webb
Guest
Posts: n/a
 
      11-03-2005
said the following on 11/3/2005 6:28 AM:

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


hover over the textbox? Use the onFocus to make it show, the onBlur to
make it go away.

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


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
}

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


Use a simple string, replace what is used so far with blank space, then
split it to get an Array.

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


What is a sodoku puzzle?

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
 
Reply With Quote
 
 
 
 
David Wahler
Guest
Posts: n/a
 
      11-03-2005
Randy Webb wrote:
> said the following on 11/3/2005 6:28 AM:
> > I suppose it would share the same logic of a sodoku puzzle thinking
> > about it, but sadly its not as exciting as that.

>
> What is a sodoku puzzle?


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

-- David

 
Reply With Quote
 
marcbinaus@hotmail.com
Guest
Posts: n/a
 
      11-04-2005
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?

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
Japanese Text not displayed on Image Generated by Servlet on winXP, Linux but displayed on Win2000 boney Java 1 12-15-2006 02:24 PM
char arrays and integer arrays... why the difference? Bill Reyn C++ 3 06-22-2004 12:01 PM
Arrays.asList() returning java.util.Arrays$ArrayList Alexandra Stehman Java 5 06-17-2004 06:04 PM
initializing arrays of arrays Mantorok Redgormor C Programming 4 09-11-2003 02:08 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57