473,490 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Javascript to PHP

1 New Member
I need to change this to PHP...the array must be in a text file that is read in and put into an array.




Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0"?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6. <title>Undergraduate Courses</title>
  7. <link rel="stylesheet" type="text/css" href="mystyles.css"/>
  8. <script type="text/javascript">
  9.  
  10.  
  11.  
  12. var courseArray=new Array(); 
  13. courseArray[0]= new Array("ACC", "202", "Financial Accounting Information", "Fall08");
  14. courseArray[1]= new Array("CHEM", "126", "Chemistry and Society", "Fall08");
  15. courseArray[2]= new Array("GTW", "100", "Gateways I", "Fall08");
  16. courseArray[3]= new Array("ITM", "200", "Introduction to Computers-Lab", "Fall08");
  17. courseArray[4]= new Array("ITM", "200L", "Introduction to Computers-Lect", "Fall08");
  18. courseArray[5]= new Array("MAT", "260" ,"Calculus I" ,"Fall08");
  19. courseArray[6]= new Array("PSY", "200", "General Psychology", "Fall08");
  20. courseArray[7]= new Array("ENG", "101", "Composition and Rhetoric I (LC)", "Spring09");
  21. courseArray[8]= new Array("GIS", "101", "International Business", "Spring09");
  22. courseArray[9]= new Array("GTW", "102", "Gateways 2", "Spring09");
  23. courseArray[10]= new Array("ITM", "251", "Visual Basic", "Spring09");
  24. courseArray[11]= new Array("MAT", "261", "Calculus II", "Spring09");
  25. courseArray[12]= new Array("ENG", "102", "Composition and Rhetoric II", "Fall09");
  26. courseArray[13]= new Array("LAN", "110", "Basic American Sign Language I", "Fall09");
  27. courseArray[14]= new Array("MAT", "262", "Calculus III", "Fall09");
  28. courseArray[15]= new Array("MAT", "300", "Differential Equations", "Fall09");
  29. courseArray[16]=new Array("MUS", "110", "Piano Class I", "Fall09");
  30. courseArray[17]= new Array("LAN", "111", "Basic American Sign Language II", "Spring10");
  31. courseArray[18]=new Array("MAT", "299", "Intro to Higher Mathematics", "Spring10");
  32. courseArray[19]= new Array("MUS", "111", "Piano Class II", "Spring10");
  33. courseArray[20]= new Array("MUS", "191", "World Music", "Spring10");
  34. courseArray[21]= new Array("PHL", "202", "Ethics", "Spring10");
  35. courseArray[22]= new Array("BIO", "112", "Environmental Science", "Fall10");
  36. courseArray[23]= new Array("CRM", "101", "Introduction to Criminology", "Fall10");
  37. courseArray[24]= new Array("MAT", "301", "Discrete Mathematics", "Fall10");
  38. courseArray[25]= new Array("MAT", "410", "Complex Analysis", "Fall10");
  39. courseArray[26]= new Array("MUS", "192", "World Music Chorus/Drumming", "Fall10");
  40. courseArray[27]= new Array("ART", "101", "Form and Idea", "Spring11");
  41. courseArray[28]= new Array("MAT", "310", "Probability and Statistics", "Spring11");
  42. courseArray[29]= new Array("MAT", "499", "History of Mathematics", "Spring11");
  43. courseArray[30]= new Array("SOC", "100", "Intro to Sociology", "Spring11");
  44. courseArray[31]= new Array("DAN", "200", "Dance/World Cultures", "Fall11");
  45. courseArray[32]= new Array("DAN", "261", "Stretching and Relaxation", "Fall11");
  46. courseArray[33]= new Array("ITM", "360", "Advanced Application Development", "Fall11");
  47. courseArray[34]= new Array("JOU", "101", "Introduction to Journalism", "Fall11");
  48. courseArray[35]= new Array("MAT", "310", "Probability and Statistics", "Fall11");
  49.  
  50.  
  51. //displays the courses in a table format 
  52. function dosstable (array) 
  53. {
  54. document.writeln("<input type='button' value='back' onclick='window.location.reload()'>")
  55. document.writeln("<table border>");
  56. document.writeln( "<tr><th>Department</th><th>Number</th><th>Title</th><th>Semester</th></tr>");
  57. var row;
  58. for (row=0; row<array.length; ++row)
  59. {
  60. document.writeln("<tr>");
  61. var col;
  62. for (col = 0; col<array[row].length; ++col)
  63. {
  64. document.writeln("<td>" + array[row][col] + "</td>");
  65. }
  66. document.writeln("</tr>");
  67. }
  68. document.writeln("</table");
  69. return;
  70.  
  71. }
  72.  
  73. // gets the user's choice for semester (semester) and goes through courseArray to see if the semester in that course matches and then outputs the course(s) 
  74. function searchSemester(semester) 
  75. {
  76. var str = "<input type='button' value='back' onclick='window.location.reload()'>";
  77. str += "<table border><tr><th>Department</th><th>Number</th><th>Title</th><th>Semester</th></tr>";
  78. for(i=0; i<=courseArray.length-1;i++){
  79. if(document.getElementById('semester').value==courseArray[i][3]) //checks to see if semester is the same as the semester in that course 
  80. {
  81. str += "<tr>";
  82. for (var col = 0; col<courseArray[i].length; ++col)
  83. {
  84. str += "<td>" + courseArray[i][col] + "</td>";
  85. }
  86. str += "</tr>";
  87. }
  88.   }
  89.   document.writeln(str);
  90. }
  91.  
  92. //gets the user's choice for department (department) and goes through courseArray to see if the department in that chouce matches and then outputs the course(s) 
  93. function searchDepartment(department){
  94. var str = "<input type='button' value='back' onclick='window.location.reload()'>";
  95. str +=  "<table border><tr><th>Department</th><th>Number</th><th>Title</th><th>Semester</th></tr>";
  96. for(i=0; i<=courseArray.length-1;i++){
  97. if(document.getElementById('department').value==courseArray[i][0]) //checks to see if semester is the same as the semester in that course 
  98. {
  99. str += "<tr>";
  100. for (var col = 0; col<courseArray[i].length; ++col)
  101. {
  102. str += "<td>" + courseArray[i][col] + "</td>";
  103. }
  104. str += "</tr>";
  105. }
  106.   }
  107.   document.writeln(str); 
  108. }
  109.  
  110. </script>
  111. </head>
  112. <body>
  113.  
  114. <p> <br/> <br/> </p>
  115.  
  116.  
  117. <label>Search by Semester:</label> 
  118. <select name="semester" id="semester">
  119. <option value="Default">Select a Semester</option>
  120. <option value="Fall08">Fall 08'</option>
  121. <option value="Spring09">Spring 09'</option>
  122. <option value="Fall09">Fall 09'</option>
  123. <option value="Spring10">Spring 10'</option>
  124. <option value="Fall10">Fall 10'</option>
  125. <option value="Spring11">Spring 11'</option>
  126. <option value="Fall11">Fall 11'</option>
  127. </select>
  128. <input type="button" value="Search" onclick="searchSemester('semester');" />
  129. <p> <br/> </p>
  130.  
  131.  
  132.  
  133.  
  134. <label>Search by Department:</label>
  135. <select id="department" name="department">
  136. <option value="Default">Select a Department</option>
  137. <option value="ACC">Accounting</option>
  138. <option value="ART">Art</option>
  139. <option value="BIO">Biology</option>
  140. <option value="CHEM">Chemistry</option>
  141. <option value="CRM">Criminology</option>
  142. <option value="DAN">Dance</option>
  143. <option value="ENG">English</option>
  144. <option value="GIS">Global Issues</option>
  145. <option value="GTW">Gateways</option>
  146. <option value="ITM">Information Technology</option>
  147. <option value="JOU">Journalism</option>
  148. <option value="LAN">Language</option>
  149. <option value="MAT">Mathematics</option>
  150. <option value="MUS">Music</option>
  151. <option value="PHL">Philosophy</option>
  152. <option value="PSY">Psychology</option>
  153. <option value="SOC">Sociology</option>
  154. <input type="button" value="Search" onclick="searchDepartment('department')"/>
  155. </select>
  156. </div>
  157. <p> <br/> </p>
  158.  
  159. <input type="button" value="View All Courses" onclick= "dosstable(courseArray)"/> 
  160.  
  161. </body>
  162. </html>
Nov 20 '11 #1
3 1727
pradeepkr13
43 New Member
Lot of manual work :)
Nov 20 '11 #2
omerbutt
638 Contributor
yeah , go ahead do that, convert the whole of it, whos stopping :D
regards,
Omer Aslam
Nov 22 '11 #3
johny10151981
1,059 Top Contributor
Simplest way to do that is open replace window in your editor

select case sensitive
Add new Array in search box
add array in replace and press search next
after finding next press replace button.

it seems lot of work but simple technical way you can replace it :)
Nov 22 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.