Thursday, September 18, 2014

Display HTML table data in a form.

Here I will be discussing how to View a dataset which are in a dynamic table. This is a continuation to the previous post I have done to create a dynamic table to retrieve the data.
The onclick functions that have been written for the three buttons will be discussed here.

First of all let me show you how to display the table data in a different form when you click on the View button.
The HTML design for the view button is as follows.

<td class="auto-style8"> <input  id="btnPview" name="btnPview" type="submit" value="View" onclick="ViewTo('<?php  echo $key->ProjectID; ?>');" /></td>

'ViewTo' is the javascript function I have written to send the 'ProjectID' to the route and through the route I will be accessing the function in the controller which will display the view form.

Javascript function

 function ViewTo(ProjectID){
   
        location.href='viewto?pid='+ProjectID;
   }

The route

Route::get('viewto', array('uses'=>'ProjectsController@viweProject'));

Note that ProjectsController@viweProject is where you ask to go to the 'viewProject' function in the 'ProjectsController'.

The function

public function viweProject()
{

$id=Input::get('pid');

$projectDetails= DB::table('projects')->where('ProjectID',$id)->get();

Session::put('PDetails',$projectDetails);

return View::make('Projects/ViewProjects');


}

The 'ViewProjects' is the HTML page designed for the display the data.


The output for the view function is as follows.







No comments:

Post a Comment