Having problem with this form and the select option and also the email is not send - codeigniter

I want this form to send email but i don't work, i don'y know where is the problem but i think the problem is in the model, also this form has a select function i cannot make it work when i choose something in the select option to send it with email
This is the controller
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Offer extends CI_Controller {
public function __construct() {
parent::__construct();
$this->load->model('admin_model');
$this->load->helper(array('form', 'url', 'text'));
}
public function index() {
$this->load->view('header.php');
$this->load->view('offer.php');
$this->load->view('footer.php');
}
public function sendOffer(){
if(isset($_POST['companyname']) && isset($_POST['sendername']) && isset($_POST['email']) && isset($_POST['number']) && isset($_POST['interest']) && isset($_POST['message'])){
$data['companyname'] = $_POST['companyname'];
$data['sendername'] = $_POST['sendername'];
$data['email'] = $_POST['email'];
$data['number'] = $_POST['number'];
$data['interest'] = $_POST['interest'];
$data['message'] = $_POST['message'];
$data['created_at'] = date("Y-m-d H:i:s");
$this->admin_model->sendOfferEmail($data);
$this->db->insert('offer',$data);
$true = "Message Sent Successfully ...";
$this->session->set_flashdata('true', $true);
redirect(base_url()."offer");
}else{
$error = "Failed To Send, Please check all inputs and try again !!!";
$this->session->set_flashdata('error', $error);
redirect(base_url()."offer");
}
}
}
This is the model
public function sendOfferEmail($data){
$MailTo = "menna.ashour#thetranslationgate.com";
$subject = "The Translation Gate Website offer".$data['created_at'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
//$headers .= "Cc: amr.hussein#europelocalize.com". "\r\n";
$headers .= 'From: The Translation Gate Website'."\r\n";
$message = '<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Falaq| Site Manager</title>
<style>
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 14px;
line-height: 1.428571429;
color: #333;
}
section#unseen
{
overflow: scroll;
width: 100%
}
</style>
<!--Core js-->
</head>
<body>
<div class="panel-body">
<div class="adv-table editable-table ">
<div class="clearfix">
<div class="btn-group">
<span class=" btn-primary" style="">
</span>
</div>
</div>
<div class="space15"></div>
<table class="table table-striped table-hover table-bordered" id="" style="overflow:scroll;border: 1px solid;width: 100%;text-align: center">
<tbody>
<tr>
<td style="background-color: #ddd;">Company Name</td>
<td style="background-color: #f9f9f9;">'.$data['companyname'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Full Name</td>
<td style="background-color: #f9f9f9;">'.$data['sendername'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Email</td>
<td style="background-color: #f9f9f9;">'.$data['email'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Phone Number</td>
<td style="background-color: #f9f9f9;">'.$data['number'].'</td>
</tr>
<tr>
<td style="background-color: #ddd;">Message</td>
<td style="background-color: #f9f9f9;">'.$data['message'].'</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>';
mail($MailTo,$subject,$message,$headers);
}
public function getInterest($interest){
$result = $this->get_where('interest',array('id' => $interest))->row();
if(isset($result->name)){
return $result->name;
}else{
return '';
}
}
}
?>
This is the view
<section id="pageBar">
<div class="container">
<div class="row">
<h1 class="page-title pull-left">Offers</h1>
<ol class="breadcrumb pull-right">
<li>Home</li>
<li>Offers</li>
</ol>
</div>
</div>
</section>
<!-- Page-Bar -->
<!-- Login Form -->
<div id="login">
<div class="container">
<div class="row">
<div class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2 col-xs-offset-0">
<form class="login-form" method="post" action="<?=base_url()?>offer/sendOffer" enctype="multipart/form-data">
<div class="form-group input-block">
<label for="name">Company Name</label>
<input type="text" name="companyname" class="form-control" id="companyname" required>
</div>
<div class="form-group input-block">
<label for="name">Full Name</label>
<input type="text" name="sendername" class="form-control" id="sendername" required>
</div>
<div class="form-group input-block">
<label for="email" style="top: 24px; font-size: 16px;">Email</label>
<input type="email" name="email" class="form-control" id="email" required="" autocomplete="off">
</div>
<div class="form-group input-block">
<label for="name" style="top: 24px; font-size: 16px;">Phone Number</label>
<input type="text" name="number" class="form-control" id="number" required="" autocomplete="off">
</div>
<div class="select-group">
<select class="form-control selectpicker" >
<option disabled="disabled" selected="" value="">Interest</option>
<option value="1">Arabic</option>
<option value="2">DTP</option>
<option value="3">Both</option>
</select>
</div>
<div class="">
<textarea name="message" id="message" class="form-control" rows="6" placeholder="Message" required="" autocomplete="off"></textarea>
</div>
<div class="text-center">
<button type="submit" class="btn btn-gray">
Submit
</button>
</div>
</form> </div>
</div>
</div>
</div>

You have disabled to blank value the select box.So you are not able select.
Remove disabled="disabled" from select box.
For mail service turn on development mode and check the error you got.

Related

Form POST request does not submit to controller but GET request works fine

I'm trying to submit a POST request to a controller but controller does not respond to my request and no error has been thrown as well, however GET request works fine.
I'm using
<button type="submit" class="btn btn-primary">Submit</button>
to send my request at the controller and this the controller that will handle my request>>
#GetMapping("/flexfieldkeysegment/{keyFlexFieldSegmentId}")
public String editCategoryForm(#PathVariable Integer keyFlexFieldSegmentId, Model model) {
String tenantName=getCurrentTenant().getUser().getTenantName();
FlexFieldKeySegment segment = keySegment.findFlexFieldKeySegmentById(tenantName, keyFlexFieldSegmentId);
model.addAttribute("keySegment",segment);
return viewPrefix+"edit_flexfield_key_segment";
}
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
layout:decorate="~{layout}">
<body>
<div layout:fragment="content">
<br /> <br /> <br />
<div class="col-md-6 col-md-offset-3">
<h3 class="sub-title theme-font"></h3>
<div class="panel panel-primary theme-font">
<div class="panel-heading">
<h3 class="panel-title">Accounting Flexfield Key Segment</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<form th:action="#{/flexfieldkeysegment/{keyFlexFieldSegmentId}(keyFlexFieldSegmentId=${keySegment.keyFlexFieldSegmentId})}"
th:object="${keySegment}" method="post"
enctype="multipart/form-data">
<p th:if="${#fields.hasErrors('global')}" th:errors="*{global}"
th:class="text-red">Incorrect data</p>
<!-- text input -->
<div class="form-group"
th:classappend="${#fields.hasErrors('keyFlexFieldSegmentCode')}? 'has-error'">
<label>Flexfield Segment Code <span style="color: red;">*</span></label>
<input type="text" class="form-control"
name="keyFlexFieldSegmentCode"
th:field="*{keyFlexFieldSegmentCode}"
placeholder="Enter Flexfield Key Segment Code" />
<p th:if="${#fields.hasErrors('keyFlexFieldSegmentCode')}"
th:errors="*{keyFlexFieldSegmentCode}" th:class="text-red">Incorrect
data</p>
</div>
<div class="form-group"
th:classappend="${#fields.hasErrors('name')}? 'has-error'">
<label>Flexfield Key Segment Name<span
style="color: red;">*</span></label> <input type="text"
class="form-control" name="name" th:field="*{name}"
placeholder="Enter Flexfield Key Segment Name" />
<p th:if="${#fields.hasErrors('name')}" th:errors="*{name}"
th:class="text-red">Incorrect data</p>
</div>
<div class="form-group"
th:classappend="${#fields.hasErrors('description')}? 'has-error'">
<label>Description<span style="color: red;">*</span></label> <input
type="text" class="form-control" name="description"
th:field="*{description}"
placeholder="Enter Flexfield Key Segment Description" />
<p th:if="${#fields.hasErrors('description')}"
th:errors="*{description}" th:class="text-red">Incorrect
data</p>
</div>
<div class="form-group"
th:classappend="${#fields.hasErrors('separatorId')}? 'has-error'">
<label for="segment_separator">Segment Separator <span
style="color: red;">*</span></label> <select name="name"
id="separator" th:field="*{separatorId}"
th:data-validation-message="#{msg.flexfieldkeysegment.separator.mandatory}"
class="form-control dropdown">
<option th:value="''" th:text="'Select'"></option>
<option th:each="separator : ${segment_separator}"
th:text="${separator.separatorName}"
th:value="${separator.separatorId}"></option>
</select>
<p th:if="${#fields.hasErrors('separatorId')}"
th:errors="*{separatorId}" th:class="text-red">Incorrect
data</p>
</div>
<div class="form-group">
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{freezeFlexfieldDefinition}"
th:value="${freezeFlexfieldDefinition}" /> <label>Freeze
Flexfield Definition</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{crossValidateSegment}"
th:value="${crossValidateSegment}" /> <label>Cross
Validate Segment</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{freezeRollUpGroup}"
th:value="${freezeRollUpGroup}" /> <label>Freeze
Rollup Group</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{allowDynamicInsert}"
th:value="${allowDynamicInsert}" /> <label>Allow
Dynamic Insert</label>
</div>
<div style="width: 30%; float: left; margin-right: 3%;">
<input type="checkbox" th:field="*{active}"
th:value="${active}" /> <label>Active</label>
</div>
</div>
</form>
</div>
</div>
<div class="box-footer">
<button type="button" class="btn btn-warning"
onclick="window.history.go(-1); return false;">
<span class="glyphicon glyphicon-arrow-left"></span> Back
</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Instead of #GetMapping, use #PostMapping. Also, annotate the 'Model' POJO with #RequestBody
#PostMapping("/flexfieldkeysegment/{keyFlexFieldSegmentId}")
public String editCategoryForm(#PathVariable Integer keyFlexFieldSegmentId, #RequestBody Model model) {
String tenantName=getCurrentTenant().getUser().getTenantName();
FlexFieldKeySegment segment = keySegment.findFlexFieldKeySegmentById(tenantName, keyFlexFieldSegmentId);
model.addAttribute("keySegment",segment);
return viewPrefix+"edit_flexfield_key_segment";
}

Who can I automatically scroll to bottom of page on load in laravel

I want to scroll to bottom of the page on page-load automatically in laravel 5.2, i tried soo much but i couldn't figure out were i went wrong, I have attached my view code below.Can u go through it please and let me know were i went wrong. Actually i'm not good at design soo please help me on it.
my code:
#section('content')
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="col-md-3 col-sm-6 col-xs-12 profile_left">
<!-- start Support Tickets -->
<ul class="list-unstyled user_data">
<li>
<div class="panel panel-success">
<div class="panel-heading"><span class="glyphicon glyphicon-filter"></span><strong> Ticket Information</strong></div>
<div class="panel-body">
<!-- Modal -->
<table class="table table" style="color: #009933;">
#if(!empty($tickets))
<tr>
<td style="font-weight: bold; ">
<small>
{{$tickets->subject}}
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
#if ($tickets->status === 'open')
<span class="label label-success">{{$tickets->status}}</span>
#elseif ($tickets->status === 'ongoing')
<span class="label label-warning">{{$tickets->status}}</span>
#elseif ($tickets->status === 'closed')
<span class="label label-default">{{$tickets->status}}</span>
#endif
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
<p style="font-family: 'Times New Roman', Times, serif; ">Agent: {{\App\User::where('_id',$tickets->user_assigned)->value('username') }}</p>
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
<p style="font-family: 'Times New Roman', Times, serif; ">Priority:
#if ($tickets->priority === 'Low')
<span class="label label-info">{{$tickets->priority}}</span>
#elseif ($tickets->priority === 'Medium')
<span class="label label-primary">{{$tickets->priority}}</span>
#elseif ($tickets->priority === 'High')
<span class="label label-danger">{{$tickets->priority}}</span>
#endif</p>
</small>
</td>
</tr>
<tr>
<td style="font-weight: bold; ">
<small>
<p style="font-family: 'Times New Roman', Times, serif; ">Last_Updated: {{$tickets->updated_at}}</p>
</small>
</td>
</tr>
#endif
</table>
</div>
</div>
</li>
<li>
<div class="panel panel-success">
<div class="panel-heading">
<span class="glyphicon glyphicon-dashboard"></span><strong> Support</strong>
</div>
<div class="panel-body">
<!-- Modal -->
<table class="table table-striped">
<tr>
<td><span class="glyphicon glyphicon-home"></span> My Support Tickets</td>
</tr>
<tr>
<td><span class="glyphicon glyphicon-open"></span> Submit Tickets</td>
</tr>
</table>
</div>
</div>
</li>
</ul>
<!-- end of Support Tickets -->
</div>
<div class="col-md-9 col-sm-9 col-xs-12">
<center>
<h2 style="color: #00BCD4;">My Ticket Feedback/<small>Your Comments History</small></h2>
</center>
<hr style="height:2px;border-width:0;color:gray;background-color:gray">
#if($tickets->status === 'closed')
#if(Auth::user()->_id === $tickets->user)
<div class="alert alert-warning" role="alert">
<center>
<p style="font-weight: bold; color:#FF9966; ">This Ticket is closed. You can reply to reopen this ticket.</p>
</center>
</div>
<div class="panel panel-success">
<div class="panel-heading">
<form action = "/reopentick/<?php echo $tickets->id; ?>" method = "post">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
<input type="hidden" name="status" value="open">
<span class="glyphicon glyphicon-pencil"></span>
<input type = 'submit' value = "Reply To Reopen Ticket" class="btn btn-link btn-xs" style="font-weight: bold; color:#009933; " />
<span class="glyphicon glyphicon-plus pull-right"></span>
</form>
</div>
</div>
#endif
#endif
<table class="table table-striped">
<tr><td>
<div class="panel-group">
#if($tickets->user == Auth::user()->_id)
<div class="panel panel-info">
#else
<div class="panel panel-success">
#endif
<div class="panel-heading">
<span class="glyphicon glyphicon-user">
<strong>
{{ \App\User::where('_id',$tickets->user)->value('username') }}
</strong>
</span>
<span class="glyphicon glyphicon-time pull-right">
{{ $tickets->created_at }}</br>
</span>
</div>
<div class="panel-body">
<p> Hello,</br>
{!! $tickets->message !!}</br>
<b>...</b></br>
Thank you,</br>
{{ \App\User::where('_id',$tickets->user)->value('username') }}
</p>
</div>
</div>
</div>
</td></tr>
<tr>
#foreach($anstickets as $t)
<td class="answer_block">
<div class="panel-group">
#if($t->user_id == Auth::user()->_id)
<div class="panel panel-info">
#else
<div class="panel panel-success">
#endif
<div class="panel-heading">
<span class="glyphicon glyphicon-user ">
<strong>
{{ \App\User::where('_id',$t->user_id)->value('username') }}
</strong>
</span>
<span class="glyphicon glyphicon-time pull-right">
{{ $t->created_at }}</br>
</span>
</div>
<div class="panel-body">
<p>Hi,</p>
{!!$t->comments!!}</br>
</div>
</div>
</div>
</td>
</tr>
#endforeach
</table>
#if(($tickets->status === 'ongoing')||($tickets->status === 'open'))
#if(Auth::user()->_id === $tickets->user)
<div class="panel panel-danger">
<div class="panel-heading">
<form action = "/closetick/<?php echo $tickets->id; ?>" method = "post" >
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
<input type="hidden" name="status" value="closed">
<input type = 'submit' value = "Close Ticket" class="btn btn-link btn-xs" style="font-weight: bold; color:#CC0000; "/>
<span class="glyphicon glyphicon-remove-sign pull-right"></span>
</form>
</div>
</div>
#endif
<br>
#if(Auth::user()->_id === $tickets->user)
<b><h1> Response</h1></b>
#else
<b><h1> Solution</h1></b>
#endif
<form action = "/tickanswert/<?php echo $tickets->id; ?>" method = "post" onsubmit="return form_submit()">
<input type = "hidden" name = "_token" value = "<?php echo csrf_token(); ?>">
<input type="hidden" name="user_id" value="<?php echo Auth::user()->id; ?>">
<input type="hidden" name="ticket_id" value="<?php echo $tickets->id; ?>">
<div class="form-group">
<textarea class="form-control" name="comments" rows="14" required></textarea>
</div>
<br>
<div class="form-group">
<div class="col-md-6 col-md-offset-4">
<button type="submit" name="submit" class="btn btn-primary btn-lg">
<i class="fa fa-btn fa-ticket"></i> SUBMIT
</button>
</div>
</div>
</form>
#endif
</div>
</div>
#endsection
#section('additional-scripts')
<script>
$( document ).ready(function() {
$('html,body').animate({
scrollTop: $('.answer_block').children('.panel-group').last().offset().top},
'slow');
alert("Hello! I am an alert box!!");
});
</script>
#endsection
Laravel cannot scroll to bottom of page. But Javascript can:
<script>
$(document).ready(function() {
$('html,body').animate({scrollTop: document.body.scrollHeight},"slow");
})
</script>

How to clear the error message when we click reset button in thymeleaf

I created a web page displays users information and register a new user. If we try to enter existing user it is showing the error message. when I refresh the page the error is still exist. How to clear the error message when we refresh or when we click reset button.I am using spring Boot Here is my code.
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>User Registration </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"
th:href="#{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
</head>
<body>
<div class="container">
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-8 col-md-7 col-sm-6">
<h1>Users</h1>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>UserId</th>
<th>USerName</th>
</tr>
</thead>
<tbody border="0">
<tr th:each="user :${users>
<td th:text="${user.userId}"></td>
<td th:text="${user.userName}" > </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-7 col-sm-6">
<h1>Register USer</h1>
<form th:action="#{/registerUser}" method="post" enctype="multipart/form-data" class="form-horizontal">
<fieldset>
<div class="form-group">
<label class="col-lg-3 control-label">Enter UserId</label>
<div class="col-lg-9">
<input type="text" class="form-control" name="userId" value=""/>
</div>
</div>
<div class="form-group">
<label class="col-lg-3 control-label">Enter UserName</label>
<div class="col-lg-9">
<input type="text" class="form-control" name="userName" value=""/>
</div>
</div>
<div class="form-group">
<div class="col-lg-12 col-lg-offset-3">
<button type="submit" class="btn btn-primary" name="button">registerUSer</button>
<button type="reset" class="btn">Reset</button>
</div>
</div>
<div th:if="*{errorMessage != null}" class="alert alert-danger" th:text="*{errorMessage}">
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
Here is my controller:
#RequestMapping(value = "/registerUser", method = RequestMethod.POST)
public String registrationForNewUSer(#RequestParam Long userId, #RequestParam String userName, Model model)
throws Exception {
//checking whether user already exist
UserModel userInfo = userInfo.findOne(userId);
if (userInfo != null) {
String str = "user already exist" + userId;
model.addAttribute("errorMessage", str);
return usersList(model);
} else {
//
return "redirect:/registerUser/" + userId + "/" + userName;
}
}
#RequestMapping(value = "/usersList", method = RequestMethod.GET)
public String usersList(Model model) {
model.addAttribute("users", userInfo.findAll());
return "usersview";
}
#RequestMapping("/registerUser/{userId}/{userName}")
public ResponseEntity<Object> authentication{
// it does authenticationprocess and add user user in database and redirect to usersview.
}

Dynamic Form Fields on Table using thymeleaf and Spring Boot

I am trying to create rows dynamically in a table using thymeleaf and spring boot.
I've looked at following urls but couldn't make it working for me.
http://forum.thymeleaf.org/I-have-problem-in-binding-the-list-of-objects-contained-inside-a-object-on-the-form-using-thymeleaf-td3525038.html#a3526497
http://stingh711.github.io/dynamic-form-with-springmvc-and-thymeleaf.html
when I click on the addCourse button, its not even going to StudentController.
please can someone help?
Student.html
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorator="layout">
<head>
<title>Students</title>
</head>
<body>
<div layout:fragment="content">
<form th:object="${student}" th:action="#{/student/create}" action="#" method="post">
<div class="row">
<div class="col-md-offset-3 col-md-6">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Add New Student</h3>
</div>
<div class="panel-body">
<input type="text" th:field="*{studentId}" class="form-control" placeholder="Student Id" />
<div style="clear: both; display: block; height: 10px;"></div>
<input type="text" th:field="*{firstName}" class="form-control" placeholder="First Name" />
<div style="clear: both; display: block; height: 10px;"></div>
<input type="text" th:field="*{lastName}" class="form-control" placeholder="Last Name" />
<div style="clear: both; display: block; height: 10px;"></div>
<input type="text" th:field="*{city}" class="form-control" placeholder="City" />
<div style="clear: both; display: block; height: 10px;"></div>
<input type="submit" class="btn btn-success pull-right"
value="Save">
</div>
</div>
</div>
</div>
<!-- start of detail section -->
<div class="row" style="margin-bottom: 50px;">
<div class="col-md-offset-2 col-md-8">
<div class="panel panel-success">
<div class="panel-heading">
<h3 class="panel-title">Student Courses</h3>
</div>
<div class="panel-body">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr class="btn-success">
<th>Course</th>
<th>End Date</th>
</tr>
</thead>
<tbody>
<tr th:each="studentCourse, rowStat : *{studentCourses}">
<td></td>
<td><input type="text" class="form-control" th:field="*{studentCourses[__${rowStat.index}__].courseId}" placeholder="Course" /></td>
<td><input type="text" class="form-control" th:field="*{studentCourses[__${rowStat.index}__].endDate}" placeholder="End Date"/>
<span class="col-sm-1 row-delete-button">
<button class="btn btn-default" th:value="*{studentCourses[__${rowStat.index}__].studentCourseId}" name="removeStudentCourse">
<i class="glyphicon glyphicon-trash icon-white"></i>
</button>
</span>
</tr>
</tbody>
</table>
<button class="btn btn-success btn-add" type="submit" name="addCourse">
<i class="glyphicon glyphicon-plus gs"></i> <b> Add</b>
</button>
</div>
</div>
</div>
<!-- end of detail -->
</form>
</div>
</body>
</html>
StudentController
#RequestMapping(value="/Student", params = {"addCourse"})
public String addCourse(Student student, BindingResult result) {
System.out.println("add new course");
student.getCourseList().add(new StudentCourse());
return "Student";
}
js.html (locatated # templates/fragments)
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<script th:src="#{/webjars/jquery/2.1.4/jquery.min.js}"></script>
style.html (locatated # templates/fragments)
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<link rel="stylesheet" th:href="#{/webjars/bootstrap/3.3.4/css/bootstrap.min.css}" />

smarty template getting blank after entering js validation

pinterest js
<script type="text/javascript">
(function(d){
var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');
p.type = 'text/javascript';
p.async = true;
p.src = '//assets.pinterest.com/js/pinit.js';
f.parentNode.insertBefore(p, f);
}(document));
</script>
css files
<link rel='stylesheet' href='css/fab-sales.css' media='all' type='text/css' />
<link rel='stylesheet' href='css/basic.css' media='all' type='text/css' />
codes
{if isset($products)}
<!-- Products list -->
<ul id="product_list" class="clear">
{foreach from=$products item=product name=products}
{assign var=foo value=$product.link}
<li class="ajax_block_product {if $smarty.foreach.products.first}first_item{elseif $smarty.foreach.products.last}last_item{/if} {if $smarty.foreach.products.index % 2}alternate_item{else}item{/if} clearfix">
<div class="left_block">
{if isset($comparator_max_item) && $comparator_max_item}
<p class="compare">
<input type="checkbox" class="comparator" id="comparator_item_{$product.id_product}" value="comparator_item_{$product.id_product}" {if isset($compareProducts) && in_array($product.id_product, $compareProducts)}checked="checked"{/if} />
<label for="comparator_item_{$product.id_product}">{l s='Select to compare'}</label>
</p>
{/if}
</div>
<div class="center_block">
<div align="center" id="prodList">
<div class="product">
<div class="prodImgBlock filler" style="cursor:pointer"><a href="{$foo|escape:'htmlall':'UTF-8'}" class="product_img_link" title="{$product.name|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'home_default')}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" {if isset($homeSize)} width="{$homeSize.width}" height="{$homeSize.height}"{/if} />{if isset($product.new) && $product.new == 1}<span class="new">{l s='New'}</span>{/if}
</a></div>
<div class="newSocialCt">
<div class="newSocialToolBar"> <span style="left: 10px;" class="newSocialTool faveIt"> <span style="position: relative;top: 4px;display: none;" class="loader"> <img src="img/tmp/ajax-loader-white.gif"> </span></span> <span class="loaderCt newSocialTool"></span> <span class="newSocialTool pinItTool" style="float:left; margin-left:-10px; margin-right:5px;"> <img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /> </span> <span class="newSocialTool" style="float:left; width:85px; margin-left:15px;">
<div id='basic-modal'> <a href='#' class='basic'><img alt="Share" src="img/tmp/tellafriend.png" border="0" /></a> </div>
</span> <span class="newSocialTool" style="float:none; margin-right:20px;">
<div class="fb-like" data-href="$foo" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true"></div>
</span> </div>
</div> </div>
</div>
<div class="productCt">
<div class="productDet" id="0"><h4>{$product.name|escape:'htmlall':'UTF-8'|truncate:35:'...'}</h4>
<p class="product_desc"><a href="{$product.link|escape:'htmlall':'UTF-8'}" title="{$product.description_short|strip_tags:'UTF-8'|truncate:360:'...'}" >{$product.description_short|strip_tags:'UTF-8'|truncate:130:'...'}</a></p>
</div>
</div></div>
<div id="push" class="clear"></div>
<div id="basic-modal-content">
<div id="tellFriendBox">
<div class="popUpHd">
<h2>Tell A Friend!</h2>
</div>
<div class="error" id="tf"></div>
<form class="" id="" method="post" action="" enctype="multipart/form-data">
<div class="eachRow">
<div>Your Name
<label style="color:#FF0000">*</label>
:</div>
<div class='field'>
<input type='text' id="name" class="required email" name="name" size='33'/>
</div>
</div>
<div class="eachRow">
<div>Friends Email Address
<label style="color:#FF0000">*</label>
:</div>
<div class='field'>
<input type='text' id="email_id" class="required email" name="email" size='33'/>
</div>
</div>
<div class="eachRow">
<div>Matter:</div>
<div class='field'>
<textarea rows='4' cols='25' id="matter" class="required" name="matter" ></textarea>
</div>
</div>
<div class="eachRow">
<div class='field'>
<input class="button" type='submit' name="tellafriend" onclick="return TellFriend(); " value="Send Mail"/>
</div>
</div>
</form>
</div>
</div>
<div style='display:none'> <img src='img/tmp/x.png' alt='' /> </div>
***after putting following javascript code for validation smarty template getting blank
<script type="text/javascript">
function TellFriend()
{
var em = /^[a-zA-Z0-9._-]+#[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
if(document.getElementById("name").value == "")
{
document.getElementById("tf").innerHTML= "* Marks Fields are Mandatory ";
document.getElementById("name").focus();
return false;
}
if(document.getElementById("email_id").value == "")
{
document.getElementById("tf").innerHTML= "* Marks Fields are Mandatory ";
document.getElementById("email_id").focus();
return false;
}
if (document.getElementById("email_id").value.search(em) == -1)
{
document.getElementById("tf").innerHTML= "Invalid Email "+"</span>";
document.getElementById("email_id").focus();
return false;
}
}
</script>
need help..and after putting $foo as URL in pinterest..pinterest count button disappering..
You should enclose the javascript in {literal}{/literal} tags
There is the great article for undestand debug process: http://blog.belvg.com/showing-php-and-sql-errors-and-debugging-a-blank-white-page-in-prestashop.html

Resources