Results 1 to 2 of 2

Thread: Passing variables into the external file path for DHTMLwindow

  1. #1
    Join Date
    Aug 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing variables into the external file path for DHTMLwindow

    1) Script Title: Script: DHTML Window

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ndow/index.htm

    Hi, all. I've worked out how to create the windows I want, as far as style and features and position go.

    Where I'm hitting the wall, though, is that I need to pass a couple of variables to the script because it may be called in different contexts. So for example I've edited the link to the function like this:

    Code:
    <a href="#" onClick="open_inventory(brain); return false">Open Window</a>
    ...and the function to this:

    Code:
    function open_inventory(invpopup){ //Define arbitrary function to run desired DHTML Window widget codes
    inventorywin=dhtmlwindow.open("ajaxbox", "ajax", "http://thrilling-tales.webomator.com/projects/test/inventory/'+invpopup+'.html", " ", "width=720px,height=525px,center=1,resize=0,scrolling=0");
    }
    ...with the idea the name of my html file will get passed as the variable "invpopup" and be placed into the file path. Now, I've found elsewhere in the project that I need to drop in the variable in different ways, like

    Code:
    '+eval(invpopup)+'
    (which doesn't work either), and I've tried varying the syntax of the way I'm referring to the variable. This is because when it comes to Javascript I tend to bumble toward my solutions.

    Anyway it seems unlikely that it can't be done, but I'm pretty much at a loss to figure out exactly how it can be done.

    Help?
    Last edited by Bradley W. Schenck; 08-04-2009 at 03:56 PM.

  2. #2
    Join Date
    Aug 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Okay, here's the answer. The function need to build a string with the entire line used to launch the popup, and then evaluate that string. Like this:

    Code:
    function open_inventory(invpopup){ //Define arbitrary function to run desired DHTML Window widget codes
    var feedme='inventorywin=dhtmlwindow.open("ajaxbox", "ajax", "http://thrilling-tales.webomator.com/projects/test/inventory/'+invpopup+'.html", " ", "width=720px,height=525px,center=1,resize=0,scrolling=0")';
    eval(feedme);
    }

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
  •