Form input data to server

vinithec22
Tera Contributor

html 

<div>
<h1>Check Your Attendance Details</h1>
<input type="text" name="name" placeholder="Enter Your Name" ng-mode="c.data.name">
<input type="text" name="roll_no" placeholder="Enter Roll No" ng-model="c.data.roll_no">
<button ng-click="vis()">Submit</button>
<p>{{data.name}}</p>
<div>

client script

api.controller=function($scope) {
  /* widget controller */
  var c = this;
$scope.vis = function(){
c.server.update();
alert(c.data.name);
}
};
server script
(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
data.name = "";
data.roll_no = "";
if(input){
data.name = input.name;
}
})(); 
i am unable get the data from the input to the server also provide some documentation links to study these things it will be helpful for me
1 ACCEPTED SOLUTION

Utpal Dutta
Tera Guru

Hi there,

 

Try below:

 

HTML:

<div>
<h1>Check Your Attendance Details</h1>
<input type="text" name="name" placeholder="Enter Your Name" ng-model="c.data.name">
<input type="text" name="roll_no" placeholder="Enter Roll No" ng-model="c.data.roll_no">
<button ng-click="c.vis()">Submit</button>
<p>{{data.name}}</p>
<div>

 

Client Script:

api.controller=function($scope) {
  /* widget controller */
  var c = this;
	c.vis = function(){
c.server.update();
alert(c.data.name);
}
};

 

Server Script:

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
	
	data.name = "";
data.roll_no = "";
if(input){
data.name = input.name;
	gs.addInfoMessage(data.name);
}

})();

 

In HTML your ng-model has a typo & you should not write ng-onClick like that. It should be c.functionName()

 

To learn more about Widget scripting please refer here.

 

If my answer helps then please mark it Helpful and Accept this solution.

 

Thanks

View solution in original post

5 REPLIES 5

Juhi Poddar
Kilo Patron

Hello @vinithec22 

Why not try creating a Catalog Item form or a Record Producer?

This approach ensures that the data is automatically saved on the server side.

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You

Juhi Poddar

i want to display records based on user input

Hello @vinithec22 

I noticed a small typo in your HTML code:

<input type="text" name="name" placeholder="Enter Your Name" ng-mode="c.data.name">

It should be ng-model, not ng-mode.

Here’s the corrected HTML code:

<div>
<h1>Check Your Attendance Details</h1>
<input type="text" name="name" placeholder="Enter Your Name" ng-model="c.data.name">
<input type="text" name="roll_no" placeholder="Enter Roll No" ng-model="c.data.roll_no">
<button ng-click="vis()">Submit</button>
<p>{{data.name}}</p>
<div>

Result:

JuhiPoddar_0-1752731460017.png

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You

Utpal Dutta
Tera Guru

Hi there,

 

Try below:

 

HTML:

<div>
<h1>Check Your Attendance Details</h1>
<input type="text" name="name" placeholder="Enter Your Name" ng-model="c.data.name">
<input type="text" name="roll_no" placeholder="Enter Roll No" ng-model="c.data.roll_no">
<button ng-click="c.vis()">Submit</button>
<p>{{data.name}}</p>
<div>

 

Client Script:

api.controller=function($scope) {
  /* widget controller */
  var c = this;
	c.vis = function(){
c.server.update();
alert(c.data.name);
}
};

 

Server Script:

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */
	
	data.name = "";
data.roll_no = "";
if(input){
data.name = input.name;
	gs.addInfoMessage(data.name);
}

})();

 

In HTML your ng-model has a typo & you should not write ng-onClick like that. It should be c.functionName()

 

To learn more about Widget scripting please refer here.

 

If my answer helps then please mark it Helpful and Accept this solution.

 

Thanks