Results 1 to 3 of 3

Thread: Javascript not working on php, please help

  1. #1
    Join Date
    Jun 2014

    Javascript not working on php, please help

    So my code, opens word file with the web information but for some reason the javascript code is not working, it is suppose to show the day and the top of the page.

    header("Content-type: application/vnd.ms-word");
    header("Content-Disposition: attachment;Filename=document_name.doc");
    echo" <html>";

    echo" <head>";

    echo"<script language=JavaScript >";

    echo"function mdy(todaysdate) { ";
    //calls the function mdy why to get our date
    echo" var month = new Array(); ";
    echo" month[0] = January; ";
    echo" month[1] = February; ";
    echo" month[2] = March;";
    echo" month[3] = April;";
    echo" month[4] = May; ";
    echo" month[5] = June; ";
    echo" month[6] = July; ";
    echo" month[7] = August;";
    echo" month[8] = September; ";
    echo" month[9] = October; ";
    echo" month[10] = November;" ;
    echo" month[11] = December;";

    echo" var d = new Date(); ";
    echo" var n = month[d.getMonth()];";

    echo "return n+ +todaysdate.getDate()+, +todaysdate.getFullYear()

    }" ;

    echo" #MainWrapper {
    margin: 0 auto 0 auto;
    width: 1400px;

    background: #FFFFFF;

    } ";
    echo"</script>" ;
    echo" <title>Form1</title> ";

    echo" hr.hr1{ ";
    echo"top: 500px; ";
    echo" position: fixed;

    } ";
    echo"hr.hr2{ ";

    echo" position: relative; " ;
    echo" top:820px;
    } ";

    echo" <form style=margin-left:300px; > ";

    echo"<br/> <br/><br/><br/>";
    echo" &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <script language=JavaScript>

    sampleDate1=new Date()
    document.write ( mdy(sampleDate1))
    echo" <br> ";

    echo" 600";

    echo"TO: &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 240/Associate Chief of Security Programs <br> ";
    echo" <br><br> " ;
    echo" FROM: &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;"; echo $_POST[From];
    echo" <br><br>";
    echo" SUBJECT: &nbsp; &nbsp; Emergency Request for Badge for Foreign National ";
    echo" <br><br><br> ";

    echo"I am requesting the emergency processing of a badge request for "; echo $_POST[name1]; echo" from <br>";
    echo $_POST[Country];echo", who will be visiting Goddard from "; echo $_POST[Date1]; echo"to "; echo $_POST[Date2]; echo". The <br> ";
    echo"purpose of this visit is ";echo $_POST[purpose]; echo" .<br> The reason the visit must happen at this time is "; echo $_POST[reason]; echo" .";

    echo"<br><br> I apologize for the lateness of this request. All of the appropriate documents for this individual have been <br> ";
    echo" uploaded to IDMax and approved by the sponsor. ";

    echo" <br><br> ";

    echo" I look forward to your approval. ";

    echo" <br>
    <br><br> ";
    echo $_POST[name2];
    echo" <br><br>";
    echo" Concurrence:";
    echo" <br><br><br> <br>";
    echo" <hr width=390 align=left > ";

    echo" <hr width=100 align=left:1px > ";
    echo" Piers Sellers, Deputy Director for Sciences and Exploration &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Date ";
    echo" <br><br>";
    echo" Approval: ";
    echo" <br><br><br> <br> ";
    echo" <hr width=390 align=left > ";
    echo" <hr width = 100 align=left:1px > ";
    echo" Robert Raimond, Associate Chief of Security Programs &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Date
    <br> ";
    echo" cc:<br> ";
    echo" 240/International Visits Coordinator/D.Brasel

    &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; ";

    echo" </form> ";

    echo" </body> ";
    echo" </html>"; ?>

  2. #2
    Join Date
    Jun 2014
    Actually is just the word document that the javascript doesn't show, but it does work on browser

  3. #3
    You might also have better results if you STOPPED using so many echo to do the job of one -- Much less you seem to have no SCRIPT or STYLE tags while outputting SCRIPT and STYLE... Not that EITHER of those really have any business in the markup.

    Though you seem to be outputting a word document, which should have Jack to do with anything generated by PHP... though that goes with the outdate HTML 3.2 / tweener 1990's markup, form when there are no input/textarea/select, use of non-breaking spaces and breaks to do padding, float or text-align's job, and general lack of proper semantics...

    Not sure what you're trying to accomplish with this, but... whatever it is, that's not how you do it.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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