SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Classic ASP Passing data from child page to parent page

    i have a classic asp webpage
    and i need to populate a textbox value on a parent page from a chaild page that pops up
    so on the parent page i have a link in javascript that opens a new popup window WHILE retaining focus on the textbox
    <input type="text" class="field_required2"
    name="sEcode"
    size="15"
    value="<%=sEcode %>"
    onBlur="validateEcode(this.value);" onFocus="setBGColor(this);" >
    <a onClick="searchEcodeFunc();"><img src="img/next.gif" border="0"></a>

    The on click will run java script and open a popup window
    <script language="javascript">
    function searchEcodeFunc() {
    document.forms.submitter.sEcode.focus();
    window.open('ecodeSearch.asp?ecodestr', null, 'height=400,width=500,status=yes,toolbar=no,m enubar=no,location=no'); }
    </script>

    on the popup page an asp function will populate a variable and session variable with my data call it session("ecode")

    i need to send this session variable or a variable to the parent page textbox that is in focus

    the only way i have so far is via session variables

    on the parent page i have a further javascript that is called by the
    onBlur="validateEcode(this.value);" of the textbox

    the javascript it runs is
    function validateEcode(myVal) {
    var textbox = document.getElementsByName('sEcode')[0]
    textbox.value ='<%=session("Ecode") %>';


    but it only works when i refresh the page and do postback as the session variable is still set to the old value

  2. #2
    SitePoint Wizard siteguru's Avatar
    Join Date
    Oct 2002
    Location
    Scotland
    Posts
    3,629
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You're forgetting the golden rule of ASP (and any other server-side language) ... ASP is executed BEFORE the display is rendered in the browser. So as far as the JavaScript in the parent is concerned the old value of the session variable is valid.
    Ian Anderson
    www.siteguru.co.uk

  3. #3
    SitePoint Member
    Join Date
    Sep 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found a solution via Javascript
    created 2 hidden fields on child and parent

    then created a java function on the child page that sets the value of the hidden field in the parent page from the hidden field value from the child page via window.opener

    window.opener.document.getElementById("ecode").value =
    document.getElementById("ecode").value;


    the java function will run on a button click
    so no need to use session variables


Bookmarks

Posting Permissions

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