A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: popUp/varible?

  1. #1
    No I can't do it by tommorow.. 1stbite's Avatar
    Join Date
    Feb 2003
    Location
    UK
    Posts
    1,300

    popUp/varible?

    Ok overview of what i need to solve:

    I want a varible (a url to an image) original set in my main html/php page, to be sent to a popup window, in this popup window it will hopefully load a standard page with a single cell table, in that table i want the varible i sent from the main page to load an image ( varible url ), and to add a little more fun, I need this pop up to be focused as 'always on top'

    any ideas/help...

    thanks in advance

    1stbite
    and in a blink of an eye...
    Media and Multimedia Courses in Nottingham - First Diploma | IMedia | HND | Foundation Degrees | BA(Hons) Top Ups.

    Give a Twit a chance!

  2. #2
    Registered User
    Join Date
    Feb 2001
    Posts
    13,044
    Hi,

    something along these lines
    Code:
    <script>
    myimg = 'test.jpg';
    win = window.open('', 'popup', 'width=100,height=100');
    win.document.write('<html><table><tr><td><img src="'+myimg+'"></td></tr></table>');
    win.documnet.close();
    win.focus();
    </script>
    Musicman

  3. #3
    No I can't do it by tommorow.. 1stbite's Avatar
    Join Date
    Feb 2003
    Location
    UK
    Posts
    1,300
    Thanks for the fast response...

    ok, i tried that but its not exactly working how i need

    ok more details:

    my main page is a list of buttons (imagelist.php)

    my popup should display a table with an image and some generic text and buttons

    I have the following on the imagelist.php

    3 function calls

    popup();
    connectToDB();
    list_all();

    popup
    PHP Code:
    function popup(){
    print 
    "<script>\n\n";

    print 
    "<!-- Begin\n";
    print 
    "function NewWindow(mypage, myname, w, h, scroll) {;\n";
    print 
    "var winl = (screen.width - w) / 2;\n";
    print 
    "var wint = (screen.height - h) / 2;\n";
    print 
    "winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'\n";
    print 
    "win = window.open(mypage, myname, winprops)\n";
    print 
    "if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }\n";
    print 
    "}\n";
    print 
    "//  End -->\n";
    print 
    "</script>\n";

    connectToDB
    PHP Code:
    function connectToDB() {
        global 
    $link$dbhost$dbuser$dbpass$dbname;
        
        
    // use pconnect - can be changed to just connect:
        
    ($link mysql_pconnect("$dbhost""$dbuser""$dbpass")) || die("Couldn't connect to MySQL");

        
    // select db:
        
    mysql_select_db("$dbname"$link) || die("Couldn't open db: $dbname. Error if any was: ".mysql_error() );
    // end func dbConnect(); 
    list_all
    PHP Code:
    function list_all(){
    global 
    $tablename;
    $result mysql_query("SELECT  * FROM `$tablename` order by number desc limit 20");
    while (
    $row mysql_fetch_array($result)) {    
        
    $number=$row["number"];
        
    $name=$row["name"];
        
    $img=$row["image"]; 
        
    $website=$row["website"];
        
    $des=$row["des"];
        
    doCSS();
        
    title();
        echo 
    "<p align=\"left\"><font size=\"1\" face=\"Verdana\">";
        echo 
    "<b><u>Number:</u></b> $number<br>";    
        echo 
    "<b><u>Name:</u></b> $name<br>";    
        echo 
    "<b><u>Description:</u></b> $des<br>";
        echo 
    "<a href=\"$img\" onclick=\"NewWindow(this.href,'$name','200','200','yes');return false;\">picture</a><br>";
    }

    mysql_free_result($result); 


    as you can see the code above actually calls the image url direct at the moment, but what i want to do is call a page called picture.php with my additional generic content and a table where the image ($img) will display...

    also the popup needs to stay unchanged when another pic link is clicked so all images open in there own pop up, like it does now

    i believe i need to modify this:

    echo "<a href=\"$img\" onclick=\"NewWindow(this.href,'$name','200','200', 'yes');return false;\">picture</a><br>";

    from the list_all function?

    i know $img will need to be swaped to picture.php but how do i now send the $img varible to the pop up using the above script?

    any ideas are welcomed

    thank you for any time and patience spent on this it much apprieciated

    1stbite
    and in a blink of an eye...
    Media and Multimedia Courses in Nottingham - First Diploma | IMedia | HND | Foundation Degrees | BA(Hons) Top Ups.

    Give a Twit a chance!

  4. #4
    Official FK nice guy and MOD 3PRIMATES's Avatar
    Join Date
    Apr 2002
    Location
    Portland Oregon
    Posts
    1,645
    Hi,
    it seems to me as if you are over thinking the whole process.
    First off, you dont need to echo your javascript function.

    Keep the javascript in the head of imagelist.php

    Now, create a link that will open the popup window with picture.php in it.

    When you open the link you want to send the image variable to picture.php

    picture.php will use that variable within an image tag.

    Your modified code is below in a zip file...

    Hope it helps.
    3PRIMATES
    Attached Files Attached Files

  5. #5
    No I can't do it by tommorow.. 1stbite's Avatar
    Join Date
    Feb 2003
    Location
    UK
    Posts
    1,300
    thanks 3P...

    not actually got round to testing the code yet, but will do soon, as it makes a lot of sense...

    as you said i think i was over complicating things

    let you know how i do, and if it works, will add a credit/link

    1stbite
    and in a blink of an eye...
    Media and Multimedia Courses in Nottingham - First Diploma | IMedia | HND | Foundation Degrees | BA(Hons) Top Ups.

    Give a Twit a chance!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center