Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    149
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Cool Hyperlink that open a menu?

    Hi,

    Can I open a short menu (one column and half dozen lines) when the hyperlink is selected by the user instead other link?

    Thank you

    Lebron

  • #2
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    You mean similar to a DHTML menu?

    Of course, but it is done with JavaScript.

    You need to use the onclick property of the anchor tag to do so.

    FOR EXAMPLE:
    Code:
    <a href="#" onclick="javascript:openMenuItem(3);">Menu Item 3</a>
    If this isn't what you are looking for, could you please explain what you need a little better or provide an example?
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #3
    Regular Coder
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    149
    Thanks
    2
    Thanked 0 Times in 0 Posts
    So so!

    Hi,

    Rewriting my question after your example...

    How to populate dhtml menu from MSSQL/MSACCESS database when the user presses the mouse button over a hyperlink (instead open other link) using JAVASCRIPT?

    Example
    ----------
    Signed <a href="#" onclick="javascriptpenMenu;">pitcher</a> Madison Bumgarner and <a href="#" onclick="javascriptpenMenu;">outfielder</a> Wendell Fairley.

    Show a "pop up menu": for example:

    American league
    European league
    Japan league

    The user finally presses the mouse and enter in one of that options. The menu otions are storaged into a database (MSSQL or MSAccess).It doens´t matter!

    Thank you for any helpful

    Lebron

  • #4
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    Ah, I get where you are going.

    That kind of communication is done either with hidden DIV tags, which are displayed when the openMenu() function is called, or by AJAX calls that basically do the same thing, but are slightly more difficult to employ.

    Which would you prefer?
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #5
    Regular Coder
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    149
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Hummm...

    The right name I want is "contextmenu" right?

    I would prefer the most easy solution... I don´t know nothing about AJAX.

    Thanks

    Lebron

  • #6
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    "ContextMenu" is the right term, but most people associate context menus with the "Right Click".

    DIV tags are the easiest way to do this.

    In your HTML, use ASP to pull your "context menu" content from the database. Then create DIV tags with a <div style="display: none;"></div>. Your menu items will open these special DIV tags based on 1) your JS, and 2) the value, passed by the JS to the DIV tag.

    EXAMPLE:
    Code:
    <html>
    
    <head>
    <title>Click here to view a hidden DIV</title>
    <script language="javascript">
    function showDiv(int) {
    	document.getElementById(int).style.display = '';
    }
    </script>
    </head>
    
    <body>
    <a href="#" onclick="javascript:showDiv('hiddenDIV');">Click here to view a hidden DIV tag</a><br />
    
    <div id="hiddenDIV" style="position: absolute; display: none; left: 200px; top: 150px; border: 1px solid #000000;">
    	<span style="font-weight: bold; font-family: Verdana; margin-left: 8px;">Content Header</span>
    	<div id="records">
    		Here is where your ASP records go<br />
    	</div>
    </div>
    </body>
    
    </html>
    Is this the only way to do it? Of course not. I use Scriptaculous a lot, especially for "pretty". I think that you will find them a great help in making sure your menus get seen in a "pretty" way.

    Let me know if you need any more help.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #7
    Regular Coder
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    149
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, I am trying it exactly now!

    Here it points to the same record: (record #1). In other words, it shown just the contents of record #1.

    <div id="records">
    Here is where your ASP records go<br />
    </div>


    I did in this way:


    <%do until rs2.EOF%>
    <%IF NOT RS2.EOF THEN%>

    <a href="#" onclick="javascript:showDiv('hiddenDIV');"><%Response.Write RS2.FIELDS("keywords")%></a><br>
    <div id="hiddenDIV" style="position: absolute; display: none; left: 200px; top: 150px; border: 1px solid #000000;">
    <span style="font-weight: bold; font-family: Verdana; margin-left: 8px;">Content Header</span>
    <div id="records"><%Response.Write RS2.FIELDS("test")%> <br />
    <br />
    </div>
    </div>
    </th>

    </tr>


    <%rs2.MoveNext%>

    <%END IF%>
    As you see there is a "loop" but it don´t moves down nor up. However It shown the content of RS2.FIELDS("test"), although just the first record!

    Thank you again

    lebron

  • #8
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    You need to do 2 loops, not just one.

    For the second loop set, do another rs lookup for just the "test" fields.

    Code:
    <div id="records">
    <%
    rs3.open "SELECT test FROM your_table WHERE test IS NULL", conn
     if not rs3.eof
      rs3.movefirst
       while not rs3.eof
           Response.Write RS3("test") & "<br />"
        rs3.movenext
       wend
     end if
    rs3.close
    %>
    <br />
    </div>
    Loops within loops aren't the best for memory management, but since you are only reading info from the database, it shouldn't slow your site any.
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #9
    Regular Coder
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    149
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well, the script works fine!

    Could you just tell me as I release the "ContentHeader". For example 50 seconds ou if move up the mouse...

    Now based on you script I hope do "rain" speaking metaphorically. In other terms "extract gold from an abandoned mine".

    Thank you again.

    Lebron

  • #10
    Regular Coder
    Join Date
    Mar 2007
    Posts
    505
    Thanks
    1
    Thanked 19 Times in 19 Posts
    That would be done with either a setTimeout() or an onmouseout() feature.

    The setTimeout would be done in your original JS call:

    Code:
    function showDiv(int) {
    	window.setTimeout(this, 5000);
    	document.getElementById(int).style.display = '';
    }
    //NOTE This is untested and may not work.

    The other option is that you can use onmouseout, which is done in the div tag.

    <div id="hiddenDIV" onmouseout="this.style.display='none';" style="position: absolute; display: none; left: 200px; top: 150px; border: 1px solid #000000;">
    To say my fate is not tied to your fate is like saying, 'Your end of the boat is sinking.' -- Hugh Downs
    Please, if you found my post helpful, pay it forward. Go and help someone else today.

  • #11
    Regular Coder
    Join Date
    Oct 2006
    Location
    Spain
    Posts
    149
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you so much!

    The script works fine. No problems.

    Best

    lebron


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •