Arrays on mouseover displayed in tooltip?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • marcbinaus@hotmail.com

    Arrays on mouseover displayed in tooltip?

    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

    #2
    Re: Arrays on mouseover displayed in tooltip?

    marcbinaus@hotm ail.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="showTo oltip(this)"

    function showTooltip(ele m){
    var a = elem.form.eleme nts['textbox1'].value;
    var b = elem.form.eleme nts['textbox2'].value;
    var c = elem.form.eleme nts['textbox3'].value;
    var masterString = "0123456789 ";
    var notUsed = masterString.re place(a,'').rep lace(b,'').repl ace(c,'');
    var notUsedArray = notUsed.split()
    alert(notUsedAr ray)
    //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.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/

    Comment

    • David  Wahler

      #3
      Re: Arrays on mouseover displayed in tooltip?

      Randy Webb wrote:[color=blue]
      > marcbinaus@hotm ail.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

      Comment

      • marcbinaus@hotmail.com

        #4
        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.ge tElementById && !document.all
        var enabletip=false
        if (ie||ns6)
        var tipobj=document .all? document.all["dhtmltoolt ip"] :
        document.getEle mentById? document.getEle mentById("dhtml tooltip") : ""

        function ietruebody(){
        return (document.compa tMode && document.compat Mode!="BackComp at")?
        document.docume ntElement : document.body
        }

        function ddrivetip(thete xt, thecolor, thewidth){


        if (ns6||ie){
        if (typeof thewidth!="unde fined") tipobj.style.wi dth=thewidth+"p x"
        if (typeof thecolor!="unde fined" && thecolor!="")
        tipobj.style.ba ckgroundColor=t hecolor
        tipobj.innerHTM L=thetext
        enabletip=true
        return false
        }
        }

        function positiontip(e){
        if (enabletip){
        var curX=(ns6)?e.pa geX : event.clientX+i etruebody().scr ollLeft;
        var curY=(ns6)?e.pa geY : event.clientY+i etruebody().scr ollTop;
        //Find out how close the mouse is to the corner of the window
        var rightedge=ie&&! window.opera?
        ietruebody().cl ientWidth-event.clientX-offsetxpoint :
        window.innerWid th-e.clientX-offsetxpoint-20
        var bottomedge=ie&& !window.opera?
        ietruebody().cl ientHeight-event.clientY-offsetypoint :
        window.innerHei ght-e.clientY-offsetypoint-20

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

        //if the horizontal distance isn't enough to accomodate the width of
        the context menu
        if (rightedge<tipo bj.offsetWidth)
        //move the horizontal position of the menu to the left by it's width
        tipobj.style.le ft=ie?
        ietruebody().sc rollLeft+event. clientX-tipobj.offsetWi dth+"px" :
        window.pageXOff set+e.clientX-tipobj.offsetWi dth+"px"
        else if (curX<leftedge)
        tipobj.style.le ft="5px"
        else
        //position the horizontal position of the menu where the mouse is
        positioned
        tipobj.style.le ft=curX+offsetx point+"px"

        //same concept with the vertical position
        if (bottomedge<tip obj.offsetHeigh t)
        tipobj.style.to p=ie?
        ietruebody().sc rollTop+event.c lientY-tipobj.offsetHe ight-offsetypoint+"p x"
        : window.pageYOff set+e.clientY-tipobj.offsetHe ight-offsetypoint+"p x"
        else
        tipobj.style.to p=curY+offsetyp oint+"px"
        tipobj.style.vi sibility="visib le"
        }
        }

        function hideddrivetip() {
        if (ns6||ie){
        enabletip=false
        tipobj.style.vi sibility="hidde n"
        tipobj.style.le ft="-1000px"
        tipobj.style.ba ckgroundColor=' '
        tipobj.style.wi dth=''
        }
        }

        document.onmous emove=positiont ip

        </script>

        and written this in the pageload
        C.Attributes.Ad d("onMouseover" , "ddrivetip(show Tooltip(C,'yell ow',
        300)")

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

        Comment

        Working...