SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    cutting down to size

    basically i want to make the far shorter

    PHP Code:

            
    var tools ""
            
    if (document.win_opts.toolbarOption.checked)
            {
                
    tools += "toolbar=1,";
            }
            if (
    document.win_opts.menubarOption.checked)
            {
                
    tools += "menubar=1,";
            }
            if (
    document.win_opts.scrollbarsOption.checked)
            {
                
    tools += "scrollbars=1,";
            }
            if (
    document.win_opts.resizableOption.checked)
            {
                
    tools += "resizable=1,";
            }
            if (
    document.win_opts.statusOption.checked)
            {
                
    tools += "status=1,";
            }
            if (
    document.win_opts.locationOption.checked)
            {
                
    tools += "location=1,";
            }
            if (
    document.win_opts.directoriesOption.checked)
            {
                
    tools += "directories=1,";
            }
            if (
    document.win_opts.copyHistoryOption.checked)
            {
                
    tools += "copyhistory=1,";
            }
            if (
    document.win_opts.customSizeOption.checked)
            {
                
    tools += "height=" document.win_opts.heightBox.value ",";
                
    tools += "width=" +  document.win_opts.widthBox.value  ",";
            }
            
    tools tools.substring(0tools.length-2);    
            
            if (
    document.win_opts.pageType[1].checked)
            { 
                var 
    urlVar ""
                
    urlVar document.win_opts.urlBox.value
                new_window 
    window.open(urlVar,"new_window",tools)
                
    new_window.document.write(tools);
            }
            else { 
                
    alert(tools);
                
    new_window window.open("","new_window",tools)
                
    new_window.document.write("<H1>Window Open Test</H1><p>"
            } 
    however i tried this yet i cannot get it to work
    (ive probably done sumthing stupid)

    PHP Code:

            
    var tools "";

            
    w_opt = new Array;
            
            
    w_opt[0] = "toolbar";
            
    w_opt[1] = "menubar";
            
    w_opt[2] = "scrollbars";
            
    w_opt[3] = "resizable";
            
    w_opt[4] = "status";
            
    w_opt[5] = "location";
            
    w_opt[6] = "directories";
            
    w_opt[7] = "copyHistory";
            
    w_opt[8] = "customSize";
            
            
    tools='';
            
    with (document.win_opts)
            {
            
                for (
    a=0;a<=w_opt.length;a++)
                {
                    if (
    w_opt[a].checked)
                    {
                        
    tools+=w_opt[a]+'= 1,';
                        
                        if (
    a==8)
                        {
                            
    tools+='height=' heightBox.value ',';
                            
    tools+='width= ' widthBox.value  ',';
                        }
                    }
                }
            
            } 
    what am I doing wrong here or is the another method

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var tools = "";
    
    w_opt =new Array("toolbar",
                     "menubar",
                     "scrollbars",                
                     "resizable",
                     "status",
                     "location",
                     "directories",
                     "copyHistory",
                     "customSize")
    
    var chk_opt=new Array();
    for (i=0;i<w_opt.length;i++){
         chk_opt.push(w_opt[i]."Option");
         }
    with (document.win_opts){      
         for (a=0;a<=w_opt.length;a++){
              if (chk_opt[a].checked){
                   tools+=w_opt[a]+'= 1,';
                   if (a==8){
                            tools+='height=' + heightBox.value + ',';
                            tools+='width= ' + widthBox.value  + ',';
                        }
                    }
                }
            
            }
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •