Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<SCRIPT LANGUAGE='javascript'>add dd_Employee('".$id1."','".$fname1."',".$sal1.");</SCRIPT>";
- echo "<SCRIPT LANGUAGE='javascript'>add dd_Employee('".$id2."','".$fname2."',".$sal2.");</SCRIPT>";
- ....
- ?>
- ...
- var details=new Array();
- function addEmployee(id,fname,salary){
- var temp=new Array(id,fname,salary);
- details[details.length]=temp;
- alert(temp);
- }
- function displayEmployee(){
- for (var i=0;i<details.length;i++)
- var temp_details=details[i];
- //Display the id,name,sal
- var id=temp_details[0];
- var name=temp_details[1];
- var sal=temp_details[2];
- alert(id);
- alert(name);
- alert(sal);
- }
- <?php
- print "details[details.length] = new Array('$id1', '$name1', '$salary1');n";
- ?>
- function displayEmployee(){
- for(var i=0;i<details.length;i++) {
- var temp_details= details[i];
- //display the id,name,sal
- var id=temp_details[0];
- var name=temp_details[1];
- var sal=temp_details[2];
- alert(id);
- alert(name);
- alert(sal);
- }
- }
- <?php
- echo "<SCRIPT LANGUAGE='javascript'>addEmployee({id:'".$id1."', name: '".$fname1."', salary:".$sal1."});</SCRIPT>";
- // ...
- echo "<SCRIPT LANGUAGE='javascript'>addEmployee({id:'".$id2."', name: '".$fname2."', salary:".$sal2."});</SCRIPT>";
- // ...
- ?>
- var details=new Array();
- function addEmployee(employeeObj){
- details[details.length]=employeeObj;
- alert(employeeObj);
- }
- function displayEmployee(){
- for(var i=0;i<details.length;i++) {
- alert(details[i].id);
- alert(details[i].name);
- alert(details[i].salary);
- }
- }
- echo "<SCRIPT LANGUAGE='javascript'>add dd_Employee('".$id1."','".$fname1."',".$sal1.");</SCRIPT>";
- echo "<SCRIPT LANGUAGE='javascript'>addEmployee('".$id1."','".$fname1."',".$sal1.");</SCRIPT>";
- <?php
- $employeeList[] = array('sdf3434', 'Bob', 123.34);
- $employeeList[] = array('wer335dg', 'Joe', 223);
- ?>
- <html>
- <head>
- <script>
- function Employees() {
- this.list = new Array();
- }
- Employees.prototype.add = function (id, fname, sal) {
- this.list.push(new Array(id, fname, sal));
- };
- Employees.prototype.display = function () {
- for(var i=0, t = this.list.length;i<t;i++) {
- var emp = this.list[i];
- alert(emp[0]);
- alert(emp[1]);
- alert(emp[2]);
- }
- };
- var employees = new Employees();
- <?php
- foreach ($employeeList as $employee) {
- list($id, $fname, $sal) = $employee;
- printf("employees.add('%s', '%s', %f);n", $id, $fname, $sal);
- }
- ?>
- </script>
- </head>
- <body>
- <a href="#" onclick="employees.display();">click</a>
- </body>
- </html>
Add Comment
Please, Sign In to add comment