www.webdeveloper.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 24

Thread: how difficult is this?

  1. #1
    Join Date
    Dec 2002
    Posts
    359

    how difficult is this?

    i have a page that has a list of comments that the user made (along with a lot of other info). this page is for a specific projectID (in the URL).

    i want to make the comments (that are in a table) links, where if the user clicks on one, a pop up appears with that comment (and the date and user, which are displayed in the parent already). The comment is in a textbox, so that the user can modify the comment as they like. Right now, the user can only add a new comment, not modify an existing one.

    then the user clicks submit (in the child) and it closes the popup, and refreshes the parent so that the modified comment is now displayed.

    Is this hard? worried about the parent/child interaction, like how i can close the popup and refresh the parent. I want a basic popup (no URL bar, etc), can i still pass info through the URL?

    any help is greatly appreciated!
    THANKS!
    Last edited by sanjuT; 02-24-2005 at 10:34 AM.

  2. #2
    Join Date
    Dec 2004
    Posts
    8,637
    The whole scenario is not that difficult (split things up into separate questions for answering) -- though you'll have to take pains to get everything set up just right. Yes, you can still pass info on the URL to a window that has no window dressings.

  3. #3
    Join Date
    Dec 2002
    Posts
    359
    thanks.

    ok, how can this be done:

    I will pass the edited comment into the database w/ a stored proc.

    then i close the window w/ a document.window.close(), or something like that?

    How can i refresh the parent page from the child page? would i refresh first, then close the child?


    THANKS!

  4. #4
    Join Date
    Dec 2004
    Posts
    8,637
    First caveat: Opening a child window without window dressings will require JavaScript.
    Second caveat: Refreshing the parent window will require JavaScript.
    Third caveat: Automatically closing the child window will require JavaScript.

    Techniques for the parent window:

    Your parent window will need to name itself so that the child window may target the parent window by name -- for refresh purposes. Place the following JavaScript in the head section of your parent document to accomplish this:
    Code:
    top.name = "myParentWindow";
    You will set up the links on your comments in the parent document so that they use the target="_blank" specification to open a new window. To alter the window dressings on this new window, you'll use the following JavaScript:
    Code:
    <a href="edit_comments.asp" target="_blank" onclick="javascript&#58;
     window.open(this.href, this.target,
                 'width=300,height=200,scrollbars,resizable');
     return false;">(your commnets)</a>
    This code could also easily be implemented into a function call:
    Code:
    <a href="edit_comments.asp" target="_blank"
     onclick="return OpenCommentWindow(this);">(your comments)</a>
    Techniques for the child window:

    The only thing the child window needs is a specially coded FORM tag:
    Code:
    <form method="post" action="parent_page.asp" target="myParentWindow" onsubmit="javascript&#58;
     window.setTimeout('top.close()',3000); return true;">
    Last edited by phpnovice; 02-25-2005 at 11:26 AM.

  5. #5
    Join Date
    Dec 2002
    Posts
    359
    THANKS A LOT!!!!!

    i have this problem now, where the popup returns a 'page cannot be found' error. in the status bar when i hover over the link the link appears right. why would that page not load in the popup?

  6. #6
    Join Date
    Dec 2004
    Posts
    8,637
    Originally posted by sanjuT
    why would that page not load in the popup?
    Sounds like you may have used the function method and got your function coding wrong. The function would look like this:
    Code:
    function OpenCommentWindow(lnk) {
     window.open(lnk.href, lnk.target,
                 'width=300,height=200,scrollbars,resizable');
     return false;
    }

  7. #7
    Join Date
    Dec 2002
    Posts
    359
    wow, thanks! that worked!

    now i am working on saving the changes. got an error about operation not allowed when the object is closed...i'll look into it.

    thanks again!!

  8. #8
    Join Date
    Dec 2004
    Posts
    8,637
    Originally posted by sanjuT
    got an error about operation not allowed when the object is closed...i'll look into it.
    If this is occurring when the child window form is submitted, you may need to increase the timeout part of the script in the FORM tag:
    Code:
    window.setTimeout('top.close()',4000);
    1000 = 1 second, etc.

  9. #9
    Join Date
    Dec 2002
    Posts
    359
    yes, it happens when submitting from the child.

    i tried making the timeout longer, same prob.

    i have to code the action of the form tag as:

    EditTicket.asp?IncidentID=(a number)

    i will try to add the incident id in, can i do that? or should i make a variable and use the variable in the form tag (instead of all the code)?

  10. #10
    Join Date
    Dec 2004
    Posts
    8,637
    Your ASP code can build the action attribute to include the incident number itself.
    Code:
    <form method="post" action="EditTicket.asp?IncidentID=<?=id?>"
     target="myParentWindow" onsubmit="javascript&#58;
     window.setTimeout('top.close()',3000); return true;">
    Last edited by phpnovice; 02-25-2005 at 03:23 PM.

  11. #11
    Join Date
    Dec 2002
    Posts
    359
    u have been a great help to me, thank you.

    i have one more question.

    i hardcoded an incident id to test. it refreshed the page, and closed the child window. but the modified comment wasn't saved. i guess i have to code in the parent to see if the comment was modified?

    i usually check a button like this:

    if request("btnSave") = "Save" then.....

    but since the action of the child is the parent, i put this type of code in the parent?

    does this make sense?

  12. #12
    Join Date
    Dec 2004
    Posts
    8,637
    Yes, the only ASP code that goes in the child document is for building the content of the child document. The parent document will receive any changes made when POSTing the child document. The parent document must process these changes before building the HTTP Response to send back to the parent window.

  13. #13
    Join Date
    Dec 2002
    Posts
    359
    how can i let the parent know that it is receiving info from the child?

  14. #14
    Join Date
    Dec 2004
    Posts
    8,637
    The same way you normally would:

    if request("btnChild") = "Save" then.....

  15. #15
    Join Date
    Dec 2002
    Posts
    359
    thanks, i'll post on monday how things went.

    AGAIN, thank you, u have been extremely helpful to me

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles