C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Javascript »

Retrieve value from popup window using javascript


Posted Date: 05 Nov 2008    Resource Type: Code Snippets    Category: Javascript
Author: Varun BansalMember Level: Gold    
Rating: 1 out of 5Points: 10



There is Code Snippets for Retrieve value from popup window on the parent window.
Let us two page
1. Default1 with one textbox (txt1) and one button(btn1)
2. Default2 with one textbox(txt2) and one button(btn2)

Aim: Open the popup window(default2) and enter the value in txt2 of default2 then click on the btn2, it closed the popup window and value of txt2 send to the txt1 of default1 page through java script...

First of all write javascript for open default2.aspx as popup window

write on default1.aspx page


<script type="text/javascript">

//Funtion of open contact window as popup window
function openwin()
{
window.open('default2.aspx','popuppage','scrollbars=no,width=400,height=400,resizable=no,left=500,top=260,toolbar=no,titlebar=no')
}

</script>

Code for btn1 on default1.aspx.(which is open the popup window on click)

<asp:Button ID="btn1" runat="server" CausesValidation="False" OnClientClick="openwin(); return false;" TabIndex="13">
Go to default2 </asp:Button>

It open the default2.aspx page as popup window on click on btn1.
Write a javascript for passing value from default2.aspx to default1.aspx

on default2.aspx page.

If you use content place holder then write this javascript code.

<script language="javascript" type="text/javascript">

function passValues()
{
window.opener.document.getElementById('ctl00_cph1_txt1').innerText = document.getElementById('<%=txt2.ClientID %>').value;
}

</script>


if you not use content place holder then write this javascript code.

function passValues()
{
window.opener.document.getElementById('txt1').innerText = document.getElementById('<%=txt2.ClientID %>').value;
}
</script>

Code for btn2 on default2.aspx...(which close the popupwindow and send the value..)

<asp:Button ID="btn2" runat="server" CausesValidation="False" Text="Send Value" OnClientClick="passValues(); window.close()" TabIndex="5" />

Wen you enter any value in text box (txt2) and click on btn2 then default2.aspx popup window closed and value send on to txt1 of default1 page..




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Passing value from popup window to the web.page using java script  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Access an Element of a html document using TagName
Previous Resource: Get the text of label using Javascript
Return to Discussion Resource Index
Post New Resource
Category: Javascript


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use