Announcement

Collapse
No announcement yet.

help: Creating popup from in php file using JS.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • help: Creating popup from in php file using JS.

    I have a HTML form: http://www.camarosource.ca/decoders/eng_vin_decoder/

    Upon pressing "Decode" a PHP file reads the code entered in the field and displays a HTML template depending on the info they entered: http://www.camarosource.ca/decoders/.../1967-1969.htm

    The code used to do this is:

    Code:
    $serial_decode = $serial;
    $file = "../../../decoders/eng_vin_decoder/1967-1969.htm";
    $read = fopen($file, "r");
    $content = fread($read, filesize($file));
    $content = ereg_replace("{VIN}", $VIN, $content);
    $content = ereg_replace("{make}", $make, $content);
    $content = ereg_replace("{make_decode}", $make_decode, $content);
    $content = ereg_replace("{model_year}", $model_year, $content);
    $content = ereg_replace("{model_year_decode}", $model_year_decode, $content);
    $content = ereg_replace("{plant}", $plant, $content);
    $content = ereg_replace("{plant_decode}", $plant_decode, $content);
    $content = ereg_replace("{serial}", $serial, $content);
    $content = ereg_replace("{serial_decode}", $serial_decode, $content);
    echo $content;
    I would like for it to display this http://www.camarosource.ca/decoders/.../1967-1969.htm is a NEW window as a Presized window that is 475 X 275 pixels.

    So to the views side, they enter info in the form, press "Decode", and a pre-size window pops up with the contents replacing the {Variables}.

    Problem is, I can't figure out how to get the pop up to work with errors and still replacing the {Variables} in the file.

    I tried the following to make the popup but it pops the window open, (error on the first page), and the variables in the html file are not replacing"

    Code:
    $serial_decode = $serial;
    $file = "../../../decoders/eng_vin_decoder/1967-1969.htm";
    $read = fopen($file, "r");
    $content = fread($read, filesize($file));
    $content = ereg_replace("{VIN}", $VIN, $content);
    $content = ereg_replace("{make}", $make, $content);
    $content = ereg_replace("{make_decode}", $make_decode, $content);
    $content = ereg_replace("{model_year}", $model_year, $content);
    $content = ereg_replace("{model_year_decode}", $model_year_decode, $content);
    $content = ereg_replace("{plant}", $plant, $content);
    $content = ereg_replace("{plant_decode}", $plant_decode, $content);
    $content = ereg_replace("{serial}", $serial, $content);
    $content = ereg_replace("{serial_decode}", $serial_decode, $content);
    $content = ereg_replace("'", '"', $content);
    echo "<html><head>";
    echo "<script language='javascript'>";
    echo "function popup() {";
    echo "pop = window.open('../../../decoders/eng_vin_decoder/1967-1969.htm', 'title', 'HEIGHT=475,WIDTH=275');";
    echo "pop.write('<html><head></head><body>hi there</body></html>');";
    echo "pop.close();";
    echo "}";
    echo "</script>";
    echo "</head><body onload='popup()'></body></html>";

    TEST IT OUT FOR YOURSELF: (WORKING NO POPUP)

    http://www.camarosource.ca/decoders/eng_vin_decoder/

    Select "1967"
    Enter "17n123456"
    Press "decode"

    WORK perfectly when NOT a popup

    NOW: (POPUP WORKS, ERRORS, BLANK PAGE, NO VARIABLES BEING REPLACED)

    http://www.camarosource.ca/decoders/...der/index2.htm

    Select "1967"
    Enter "17n123456"
    Press "decode"

    You'll notice the popup works. But the variables are NOT being replaced like they should, AND there is a javascript error on the first plage which turns to a white page.

    The error: "Line 1:
    "Chars: 121
    "Error: Object doesn't support this property or method.
    "Code: 0
    "URL: http://www.camarosource.ca/php/decod...n_decoder2.php

    PLEASE HELP! THANKS
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X