Javascript Tooltip / Posts /

Javascript issue in tooltip

13

This is a very simple classic ASP code which works fine.  It simply displays what I type in the textbox

TEST1.asp

<%@ Language=VBScript %>
<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 </head>
 <body>
  <form name="form1" id="form1" method="post" action="test1.asp">
   <table>
    <tr>
     <td>ID</td>
     <td>
      <input type="textbox" name="user_id" value="<%=request("user_id")%>">
      <input type="button" name="_submit" value="submit" onClick="javascript:document.form1.submit();"> 
     </td>
    </tr>

    <tr>
     <td colspan="2">
      This is your input: <%=request("user_id")%>
     </td>
    </tr>
   </table>
  </form>
 </body>
</html>

Another program that uses tooltip.ajax to call TEST1.asp.  The tooltip is displayed but when I click the "submit" button, the form is not submitted at all.

TEST2

<%@ Language=VBScript %>
<!DOCTYPE html>
<html>
 <head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="tooltip.js" type="text/javascript"></script>
    <link href="tooltip.css" rel="stylesheet" type="text/css" />
 </head>
 <body>
  <form name="form1" id="form1" method="post" action="test2.asp">
   <table>
    <tr>
     <td>
      <b onmouseover="var timer = new Date().getMilliseconds();tooltip.ajax(this,'test1.asp?'+timer,null,{position:1})">Click me</b>
     </td>
    </tr>
   </table>
  </form>
 </body>
</html>

Does tooltip support javascript?  I want to show the result in the tooltip.

Wilson  10 years ago   viewed: 6672    

5 Answers

-1

Milo, thanks for the answer.  I removed the <form> in TEST2.asp and the javascript of TEST1.asp works inside the tooltip, the form in TEST1.asp can be submitted.

Three questions still.

1. Though the form in TEST1.asp can be submitted, but the tooltip disappear at the same time, and the result is posted back to the same page.  I would like to see the result in the tooltip, how to do it?

2. Is it really a case of multiple <form>?  Actually each individual program contains 1 <form> only.  If I just simply use javascript window.open('TEST1.asp) to call TEST1.asp in a pop-up window, the form can be submitted and the result is displayed inside the pop-up window.

3.  I think it is common that an application calls another program e.g. I have a small program, say "CheckUser.asp" that asks user to enter ID and password, then validates with the user database and posted back whether the user id valid.  "CheckUser.asp" contains a <form> obviously.  In the main application e.g. "StockQuote.asp" which contains a <form> for user to enter stock number, stock chart type.  If user selects some special options within the form, I use the tooltip.ajax to call the "CheckUser.asp" to validate the user identity first before the user can proceed.  It seems tooltip.ajax does not return the beaviour as expected because the 2 programs "CheckUser.asp" and "StockQuote.asp" contains a <form>.

Wilson
  10 years ago
1

Milo, I think multiple <form> is supported.  The problem above is that both <form> is using the same id (form1).  I changed the form id in TEST.asp to form2 and it works now.

But the problem that tooltip disappear and the results posted back to the browser page persists.  Anyway to handle so that the results posted back inside the tooltip?


 

Wilson
  10 years ago
0
Glad to know you have made the two forms working. According to my knowledge, ASP.NET does not allow two forms on the same page. Menucool's tooltip will import the 2nd Form via Ajax and append it into the current page's Form. That is why I am thinking it will not work. But it works according to your test.

For your second question, I guess the submit will cause the current page to post back and the current page will re-load. That is why the tooltip will disappear. To make it popup again, you have to call the tooltip.pop function again immediately after the postback. Maybe you can implement this by registering the script in your code behind:

Page.ClientScript.RegisterStartupScript(...)

Milo   10 years ago
0

If I remove the javascript portion and change the statement to <input type="submit" name="_submit" value="submit">, the form can be submitted in tooltip, however the tooltip disappears at the same time.  The result is shown in the browser.  I want to show the result in the tooltip.
Wilson
  10 years ago
0
ASP.NET Web Forms allow only one <form> element on a page, and getting the posted back to the same page every time something updates or postbacks. Trying to use multiple forms is not a good idea.

You have brought another form into your test2 page. I guess that is why it is not working properly.
Milo   10 years ago

   

Your name*
Password
(Optional. Used to modify this post afterwords)
+ =  

Ask your Own Question

  • If your question is related to the topic of this post, you can post your question to this page by clicking the "Post a reply" button at left;

  • When you want to start a new page for your question: