SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can you help with this small function?

    I have written a small function,see below, but cannot get it to work properly.
    The window.open is returning 'cardetail' as the url rather than the value of variable cardetail - /cardetail_0.htm

    How do I pass the variable value to the window.open function?

    Any help would be much appreciated.
    DBG


    function view(str1){
    cardetail="/cardetail"+"_"+str1+".htm";
    if (!available[str1]){cardetail="/cardetail_0.htm";}
    alert (cardetail);
    window.open("cardetail","","top=40,left=40,width=200,height=200");
    }

  2. #2
    SitePoint Zealot
    Join Date
    Sep 2002
    Location
    Calgary
    Posts
    160
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    function view(str1){
    cardetail="/cardetail"+"_"+str1+".htm";
    if (!available[str1]){cardetail="/cardetail_0.htm";}
    alert (cardetail);
    window.open("cardetail","","top=40,left=40,width=200,height=200");
    }
    Instead of available, use cardetail;

    Code:
    function view(str1){
    cardetail="/cardetail"+"_"+str1+".htm";
    if (!cardetail[str1]){cardetail="/cardetail_0.htm";}
    alert (cardetail);
    window.open("cardetail","","top=40,left=40,width=200,height=200");
    }

  3. #3
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm, the problem to me seems to be the quotes around cardetail in the first argument of window.open. In otherwords, you are literally sending the string "cardetail" as the URL, instead of the string value contained by cardetail.
    Code:
    window.open("cardetail","","top=40,left=40,width=200,height=200");
    Remove those, and you should be ok
    Code:
    function view(str1){
    cardetail="/cardetail"+"_"+str1+".htm";
    if (!available[str1]){cardetail="/cardetail_0.htm";}
    alert (cardetail);
    window.open(cardetail,"","top=40,left=40,width=200,height=200");
    }
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the try Fabbricino but the available variable is unrelated to the problem.

    Thank you Beetle - So obvious when it is pointed out - why didn't I think of that?

    As ever your solution was spot on.

    David Gale


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
  •