/    Sign up×
Community /Pin to ProfileBookmark

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.

<?php
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;
position:relative;
width: 1400px;

background: #FFFFFF;

text-align:justify;

} “;
echo”</script>” ;
echo” <title>Form1</title> “;

echo”<style>”;

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

} “;
echo”hr.hr2{ “;

echo” position: relative; ” ;
echo” top:820px;

} “;
echo”</style>”;
echo”</head>”;
echo”<body>”;

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))
</script>”;

echo” <br> “;

echo” 600″;

echo”<br><br><br>”;

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>”; ?>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@tsg91authorJun 12.2014 — Actually is just the word document that the javascript doesn't show, but it does work on browser
Copy linkTweet thisAlerts:
@deathshadowJun 12.2014 — 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.
×

Success!

Help @tsg91 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...