SitePoint Sponsor

User Tag List

Results 1 to 20 of 20
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    multi div => (newbie)

    Hi again,

    i'm gonna ask you a stupid question it think
    however i'm a newbie so ....

    I'm still using the same code as the div 3 :
    http://www.cross-browser.com/x/examples/drag1.php

    however here is the question..
    i will need to put something like 3 different div...
    all those 3 div will need the same script as nothing will change except the content!

    is there a way to modify the existent script so that it do not only refer to the idv id 3 but also to others???

    Hope i've been clearer...
    thanks in advance

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    can someone put me on the right track??

  3. #3
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look at this: xFenster

  4. #4
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes perfect

    however another question!
    how can i avoid having a lot of show layer and close layer..
    can i have only one function
    that get the id of the div
    and then open the right one?
    function showLayer(){

    Could be easier and better!!!
    thanks in advance

  5. #5
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have no idea what you are talking about. At some point you are going to have to show me your page.

  6. #6
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I simplu mean that that i want button to let appear a div ou hide it
    imagine i have 5 divs.. i don't want to have 5 showlayer script et 5 hidelayer script

    how can i just have of function
    that get the id of the div
    and then following this id hide or open the right div...

    hope it clearer...

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    is there anyone who could have an answer?

  8. #8
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    New Jersey
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make your function so that it can accept an argument and pass it the div object that needs to be toggled.

    or you can use event.srcElement to get the button that was pressed to initiate the action...

  9. #9
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    humh sorry but i'm a newbie in javascript..

    could you please explain with more details...
    thanks

  10. #10
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    New Jersey
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post an example function and ill show you what i mean...(like make the function for div1 to be toggled and post it and ill show you how to make that function work for all of the divs...)

  11. #11
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    here is the fen1 script:
    Code:
    <DIV class=fenster id=fen1>
    <DIV class=fenMaxBtn id=fenMaxBtn1 title="Click to Maximize/Restore"></DIV>
    <DIV class=fenBar id=fenBar1 title="Drag to Move">xFenster 1</DIV>
    <div id="fermer" style="position:absolute; top:0; right:0" ;><a onclick="javascript:MinLayer();">min</a><a onclick="javascript:FermeLayer();">fermer</a></div>
    
    <DIV class=fenContent>
    
    Content div 1
    </DIV>
    <DIV class=fenResBtn id=fenResBtn1 title="Drag to Resize"></DIV></DIV>

    and the function to hide it..
    Code:
    function MinLayer(){
    document.getElementById("fen1").style.visibility="hidden";
    }
    thanks in advance

  12. #12
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Location
    New Jersey
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok if i were you i would do something like this...

    function MinLayer(theDiv){
    document.getElementById(theDiv).style.visibility="hidden";
    }

    theDiv is the argument being passed to the function in this case it is going to be the name of the div that you want to hide.

    Now when you call the function you need to do this MinLayer("fen1") and replace "fen1" for the appropriate div for each button...

    i think for your situation this is the easiest solution.

    Hope this helps

    ~Mr_Bonez

  13. #13
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    humh thanks

    but i'm not sure i've understand everyhting...
    i understand the function in itself but i don't see how to replace fen1....
    in order fot the function to understand what div i'm taking aboutN??

    Thanks..

  14. #14
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    forget about it i've just tried the same thing in another page and it works!!

    that's what we can call, informatic miracle!!!

  15. #15
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oups sorry that was not the message for this post... gloups
    Help is still required..

    thanks in advance

  16. #16
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i've just tried something..

    i just paste your code!
    Code:
    function MinLayer(theDiv){
    document.getElementById(theDiv).style.visibility="hidden";
    }
    and test with a link:
    Code:
    a onclick="javascript:MinLayer(fen1);">min</a>
    but this doesn't work..
    that should be normal because i don't know how the computer identify thediv??
    can you help me ?

  17. #17
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    as a newbie i've made another try but still doesn"t work

    Code:
    function MinLayer(theDiv){
    var theDiv = nom;
    document.getElementById(theDiv).style.visibility="hidden";
    }
    and i've tried that... might not be coherent...

    Code:
    <a onclick="javascript:MinLayer(nom=fen1);">min</a>
    it tell me that an object is required... i guess nom=fen1 is not the good syntax...

  18. #18
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you have chosen to use the X library, then you should browse thru the function reference and utilize the functions which are made available by including the library - for example: xHide() and xShow().

    I also suggest that you go through a basic Javascript tutorial. You have chosen a non-trivial DHTML project for your (seemingly) first Javascript project.

    It would also be very helpful to study the code for some of the demos on my site which utilize the X library.

    For your above question, all you need is:
    Code:
    <span onclick="xHide('fen1')">min</span>

  19. #19
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i understant but my question was due to another thing..
    indeed i do not only want a hide thing!!
    i also want a close button in case there is textareas..

    so i need a xclose function...
    which detect the id i want to close and close it.. and refresh it also!

    function xclose(){
    document.forms['form1'].reset();
    document.getElementById("fen1").style.visibility="hidden";
    }

  20. #20
    SitePoint Enthusiast
    Join Date
    Mar 2005
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how can make work such a function??


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
  •