Results 1 to 9 of 9

Thread: LBGW run function onload of window

  1. #1
    Join Date
    Jun 2008
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default LBGW run function onload of window

    Hi,

    am having trouble getting the function below to run onload of a page inside a LBGW window

    at bottom of window
    <script language="JavaScript">
    toggleSet(document.forms[0].x_siteid[<%=cint(session("siteid")-1)%>]);
    </script>

    have tried
    <script language="JavaScript">
    toggleSet(document.forms["formname"].x_siteid[<%=cint(session("siteid")-1)%>]);
    </script>

    in "parent" page
    <script type="text/javascript">
    function toggleSet(rad) {
    var type = rad.value;
    var list=document.getElementsByTagName('div')
    for(var k=0,elm;elm=list[k];k++)
    if(elm.className=='item')
    elm.style.display = elm.id==type? 'inline':'';
    }
    </script>

    should i try and run it within the lightbox.js script?

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    What is the <%....%> code? Is that ASP?
    With two (or more) languages mixed, please explain how they work together and which one is the problem (if you know).
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    The mixture of languages can be confusing. But if we assume that the asp or asp-like part is OK and is being parsed as expected by the server, it would probably output an integer. So you would have something like:

    Code:
    toggleSet(document.forms[0].x_siteid[3]);
    But, from what you say it appears that the toggleSet function is on the parent page, and that this code is in an iframe of that parent page. So you would at least have to do:

    Code:
    parent.toggleSet(document.forms[0].x_siteid[3]);
    Now, you've made no indication of which of these two pages that forms[0] is on. If it is on the parent page, you would also need to add:

    Code:
    parent.toggleSet(parent.document.forms[0].x_siteid[3]);
    Additionally, this pretty much assumes that wherever the form is, that it has a property (possibly an element - an input, button or textarea, or perhaps just some assigned property) that can be addressed as x_siteid[#], where # is an integer.

    Finally, for now, since session("siteid") must at least be a number or be a string that the server can type convert to a number (otherwise there would be an error on the server side), session("siteid") might still be out of range of what is expected as a possible property value for the x_siteid property of the form.

    This last bit can be observed (what cint(session("siteid")-1) works out to be on a case by case basis), by viewing the served source code of the page that has this on it.

    Firefox with the developer's extension for it added is good for that as it would allow you to view the iframe's page's source without having to load the page separately.

    If you want more help:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Jun 2008
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    hi - apologies the browser output for that line is now

    Code:
    toggleSet(document.forms["homesetup"].x_siteid[0]);
    - changed forms[0] to forms["homesetup"] which is the name of the form in the LBGW window
    - x_siteid is a radio button in the LBGW window
    - if the LBGW page is run direct in the browser it runs fine (if i include the toggleSet function in the page)
    - this is an intranet site so cant 'easily' give a demo

    if i run

    Code:
    <script type="text/javascript"> 
    alert('hello');
    </script>
    at the bottom of the LBGW window it doesnt run?

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    LBGW has only one method for importing pages to its 'window'. This is AJAX. AJAX imported content generally will not run scripts that are included. And the LBGW 'window' is not a true window, it is just a divsion to which the external markup is imported. You need something like:

    http://www.dolem.com/lytebox/

    or:

    http://www.stickmanlabs.com/lightwindow/

    I'm sure there are several others, that can optionally import the external page to an iframe. There may even be other lightbox type scripts that can import via AJAX while optionally running a script on the imported page. But perhaps not.

    Then (if using an iframe 'box' from a script that can do that) if the form is on the page in the window, and the function is on the parent page:

    Code:
    parent.toggleSet(document.forms["homesetup"].x_siteid[0]);
    should work. If not, you may always just use:

    Code:
    toggleSet(document.forms["homesetup"].x_siteid[0]);
    and include the toggleSet function on the page in the iframe box.

    If you do by chance come across a lightbox type script that can import via AJAX while optionally running a script on the imported page, you may then most likely be able to use:

    Code:
    toggleSet(document.forms["homesetup"].x_siteid[0]);
    with toggleSet on the 'top' page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Jun 2008
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    can you tell me if i can show a hidden div onload of a LBGW modal div?


    popup
    [/code]
    <style>
    div.item{display: none; padding: 8px;}
    </style>
    <form name="homesetup" id="homesetup">
    <div id='1' class='item'>
    <!--content-->
    </div>

    <div id='2' class='item'>
    <!--content-->
    </div>

    <div id='3' class='item'>
    <!--content-->
    </div>
    </form>
    [/code]

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    As far as I can see, no. You might be able to hack something together for it. But the two other scripts I mentioned, if you use their iframe methods, you can do just about anything like that you might want.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. #8
    Join Date
    Jun 2008
    Posts
    9
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    thanks v.much for all your help - fixed this by using ASP to set the initial display style depending on x_siteid [messy ;-)]

    Code:
    <%if cint(j) = cint(x_siteid) then
    showdept = "style=""display: inline;"""
    else
    showdept = "style=""display: none;"""
    end if%>
    
    <style> 
    div.item{display: none; padding: 8px;} 
    </style>
    <form name="homesetup" id="homesetup">
    <div id='1' class='item' <%=showdept%>> 
    <!--content-->
    </div>
    
    <div id='2' class='item' <%=showdept%>> 
    <!--content-->
    </div>
    
    <div id='3' class='item' <%=showdept%>> 
    <!--content-->
    </div>
    </form>
    Last edited by burnside; 12-07-2009 at 09:23 AM.

  9. #9
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    From that server side code it looks like you want to either show all three divisions or none of them, right?

    If so, you could do like:

    Code:
    <%if cint(j) = cint(x_siteid) then
    showdept = "inline"
    else
    showdept = "none"
    end if%>
    
    <style> 
    div.item{display: <%=showdept%>; padding: 8px;} 
    </style>
    <form name="homesetup" id="homesetup">
    <div id='1' class='item'> 
    <!-- content -->
    </div>
    
    <div id='2' class='item'> 
    <!-- content -->
    </div>
    
    <div id='3' class='item'> 
    <!-- content -->
    </div>
    </form>
    Also: The id attribute is technically not allowed to begin with a number. So you may want to change that. The native display value for a div is 'block', so you may want to use that in place of 'inline'. But 'inline' is fine if that is what you intend. Style sections belong in the head of the page. My asp is a bit rusty. In most languages you need a == for comparison.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •