2012-08-31 22 views
0

這樣例如:如何使用jquery + ThickBox的打開窗體,並傳遞值母體形式

aa.jsp(母體形式)

<head> 

    <script language="javascript" type="text/javascript" src="<%=basePath%>js/jquery-1.7.2.min.js"></script> 
    <script language="javascript" type="text/javascript" src="<%=basePath%>js/thickbox.js"></script> 

    <link rel="stylesheet" type="text/css" href="<%=basePath%>js/thickbox.css"> 

</head> 
<body> 

    <a href="bb.jsp?TB_iframe=true&placeValuesBeforeTB_=savedValues&height=400&width=170" title="input value" class="thickbox"> 
     <input type="text" name="txtA" id="txtA"/> 
    </a> 

</body> 

我使用jquery和ThickBox的的JS在頭上。並應用它們。點擊txt文本框打開子頁面。

bb.jsp(分體)

<body> 
    <input type="text" name="txtB" id="txtB"> 
</body> 

有一個文本框txtB在子頁面。

如何在bb.jsp的文本框txtB中輸入上下文,並將上下文傳遞給aa.jsp的父頁面。然後,上下文將在父頁面的文本框txtA中顯示。

回答

0

我找到一個解決方案,這樣的:ThickBox時的 進口JS

<script src="Upimg/jquery-1.1.3.1.pack.js" type="text/javascript"></script> 
<script src="Upimg/thickbox-compressed.js" type="text/javascript"></script> 
class ="thickbox" Where you want to open the sub form, you can add// 
<a href="bb.jsp?TB_iframe=true&amp;height=250&amp;width=400" title="add a caption to title attribute/or leave blank" class="thickbox">case 1</a> 
// write js in parent page, like: 
function check(id){ 
alert(id); 
} 

打開bb.jsp頁面

<script type="text/javascript"> 
function check() 
{  
window.parent.check(1); 
} 
</script> 
<body> 
<input type="text" name="txtB" id="txtB" onclick="check();"> 
</body> 
時,該事件將被稱爲
相關問題