Be yourself; Everyone else is already taken.
— Oscar Wilde.
This is the first post on my new blog. I’m just getting this new blog going, so stay tuned for more. Subscribe below to get notified when I post new updates.
Here you can find small coding snippets in case you got stuck in the middle of the programming
Be yourself; Everyone else is already taken.
— Oscar Wilde.
This is the first post on my new blog. I’m just getting this new blog going, so stay tuned for more. Subscribe below to get notified when I post new updates.
function getValues()
{
return [value1,value2];
}
var values = getValues();
var first_value = values[0];
var second_value = values[1];
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction()
{ var nums = {4:"four",5:"five"};
for(var key in nums)
{
var x = document.getElementById("category");
var option = document.createElement("option");
option.text = nums[key];
option.value = key;
x.add(option);
}
}
</script>
</head>
<body>
<select id="category">
<option value="1">one</option>
<option value="2">two</option>
<option value="3">three</option>
</select>
<button onclick = "myFunction()">Click here to add</button>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script>
function myFunction()
{
var array1 = [551,445,665,551,778,443,665,334,445];
var array2 =[];
console.log("array1length "+array1.length+"\n");
var display1 ="array1length "+array1.length+"\n";
for(var i=0;i<array1.length;i++)
{
display1 +=array1[i]+"\n";
if(array2.indexOf(array1[i])<0)
{
array2.push(array1[i]);
}
}
console.log("array2length "+array2.length+"\n");
var display2 ="array2length "+array2.length+"\n";
for(var j=0;j<array2.length;j++)
{
display2 +=array2[j]+"\n";
}
document.getElementById("array1display").innerHTML = display1;
document.getElementById("array2display").innerHTML = display2;
}
</script>
</head>
<body>
<p id="array1display"></p>
<p id="array2display"></p>
<button onclick = "myFunction()">Click here to see arrays</button>
</body>
</html>
| Type | internal id |
| Assembly Build | Build |
| Assembly Unbuild | Unbuild |
| Bill | VendBill |
| Bill CCard | VendCard |
| Bill Credit | VendCred |
| Bin Putaway Worksheet | BinWksht |
| Bin Transfer | BinTrnfr |
| Bill Payment | VendPymt |
| Cash Refund | CashRfnd |
| Cash Sale | CashSale |
| Check | Check |
| Commission | Commissn |
| Credit Card | CardChrg |
| Credit Memo | CustCred |
| Currency Revaluation | FxReval |
| Customer Deposit | CustDep |
| Customer Refund | CustRfnd |
| Deposit | Deposit |
| Deposit Application | DepAppl |
| Expense Report | ExpRept |
| Inventory Adjustment | InvAdjst |
| Inventory Count | InvCount |
| Inventory Distribution | InvDistr |
| Inventory Transfer | InvTrnfr |
| Inventory Worksheet | InvWksht |
| Invoice | CustInvc |
| Item Fulfillment | ItemShip |
| Item Receipt | ItemRcpt |
| Journal | Journal |
| Opportunity | Opprtnty |
| Payment | CustPymt |
| Purchase Order | PurchOrd |
| Quote | Estimate |
| Return Authorization | RtnAuth |
| Sales Order | SalesOrd |
| Sales Tax Payment | TaxPymt |
| Statement Charge | CustChrg |
| Transfer | Transfer |
| Transfer Order | TrnfrOrd |
| Vendor Return Authorization | VendAuth |
| Work Order | WorkOrd |
Reference:
http://blog.prolecto.com/2014/01/03/netsuite-searchfilter-internal-transaction-type-codes/
<html>
<head>
<script>
var theDate = new Date();
theDate.setDate(theDate.getDate()-42);
document.getElementById('datediv').value = theDate;
</script>
</head>
<body>
Date 42days ago is
<div id="datediv"></div>
</body>
</html>
/**
*@NApiVersion 2.0
*@NScriptType ClientScript
*/
define(['N/ui/dialog','N/search'],
function(dialog,search) {
function pageInitfun(Scriptcontext)
{
var cRecord = Scriptcontext.currentRecord;
var mode = Scriptcontext.mode;
var options = {
title: 'Hello!',
message: 'pageInit Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' mode: '+mode
});
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function fieldChangedfun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var sublistId = Scriptcontext.sublistId;
var fieldId = Scriptcontext.fieldId;
var linenum = Scriptcontext.line;
var columnid = Scriptcontext.column;
var options = {
title: 'Hello!',
message: 'validateInsert Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' sublistid: '+sublistId+' fieldId: '+fieldId+' linenum: '+linenum+' columnid: '+columnid
});
return true;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function lineInitfun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var sublistid = Scriptcontext.sublistId;
var options = {
title: 'Hello!',
message: 'lineInit Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' sublistid: '+sublistId
});
return;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function postSourcingfun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var sublistId = Scriptcontext.sublistId;
var fieldId = Scriptcontext.fieldId;
var options = {
title: 'Hello!',
message: 'postSourcing Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' sublistid: '+sublistId+' fieldId: '+fieldId
});
return;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function saveRecordfun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var options = {
title: 'Hello!',
message: 'saveRecord Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord
});
return true;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function sublistChangedfun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var sublistId = Scriptcontext.sublistId;
var options = {
title: 'Hello!',
message: 'sublistChanged Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' sublistid: '+sublistId
});
return true;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function validateDeletefun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var sublistId = Scriptcontext.sublistId;
var options = {
title: 'Hello!',
message: 'validateDelete Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' sublistid: '+sublistId
});
return true;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function validateFieldfun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var sublistId = Scriptcontext.sublistId;
var fieldId = Scriptcontext.fieldId;
var linenum = Scriptcontext.line;
var columnid = Scriptcontext.column;
var options = {
title: 'Hello!',
message: 'validateField Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' sublistid: '+sublistId+' fieldId: '+fieldId+' linenum: '+linenum+' columnid: '+columnid
});
return true;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
function validateInsertfun(Scriptcontext) {
var cRecord = Scriptcontext.currentRecord;
var sublistId = Scriptcontext.sublistId;
var options = {
title: 'Hello!',
message: 'validateInsert Triggered!'
};
try {
dialog.alert(options);
log.debug ({
title: 'Success',
details: 'cRecord: '+cRecord+' sublistid: '+sublistId
});
return true;
}
catch (e) {
log.error ({
title: e.name,
details: e.message
});
}
}
return {
pageInit: pageInitfun,
fieldChanged: fieldChangedfun,
lineInit: lineInitfun,
postSourcing: postSourcingfun,
saveRecord: saveRecordfun,
sublistChanged: sublistChangedfun,
validateDelete: validateDeletefun,
validateField: validateFieldfun,
validateInsert: validateInsertfun
};
});
HTML page content
<!doctype html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<form id="sampleform" method="post">
<div>
Firstname:
<input type="text" name="firstname" id="firstname" />
Email:
<input type="text" name="email" id="email" />
<input type="submit" name="subBtn" id="subBtn" value="Clickhere" />
</div>
<div id="results"></div>
</form>
<script type="text/javascript">
$(document).ready(function() {
$('#sampleform').submit(function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: 'phppage.php',
data: $(this).serialize(),
success: function(resp)
{
var jsonData = JSON.parse(resp);
// user is logged in successfully in the back-end
// let's redirect
if (jsonData.success == "1")
{
$('#results').append("Firstname "+jsonData.firstname + "<br>");
$('#results').append("Email "+jsonData.emailid);
}
else
{
$('#results').append(jsonData.message");
}
}
});
});
});
</script>
</body>
</html>
PHP Page
<?php
if (isset($_POST['firstname']) && $_POST['firstname'] && isset($_POST['email']) && $_POST['email']) {
echo json_encode(array('success' => 1,
"emailid" =>$_POST['email'],
"firstname" =>$_POST['firstname']));
} else {
echo json_encode(array("failure"=>0,
'message' => ="there is something wrong with the data"));
}
?>
Both count() and sizeof() returns number of elements in an array.
sizeof() is an alias of count().
<?php
$arrray1 = array("ele1","ele2","ele3");
echo "using sizeof function ".sizeof($array1);
echo "using count function ".count($array1);
?>
HTML code
<html>
<head></head>
<bosy>
<form action = "<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method = "POST">
<input type = "text" name = "first_name" id = "first_name">
<input type = "text" name = "last_name" id = "last_name">
<input type = "text" name = "emailed" id = "emailed">
</form>
</body>
</html>
PHP Code
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
echo "First Name ". $_POST['first_name'];
echo "Last Name ". $_POST['last_name'];
echo "Email ". $_POST['emailid'];
}
?>
Finding HTML elements using ID, Classname, Tag, CSS Selectors
Javascript
var val = document.getElementById("id1"); //using id
var val = document.getElementsByClassName("cls"); //using classname
var val = document.getElementsByTagName("p"); //using tag name
var val = document.querySelectorAll("p.cls"); //using selector
jQuery
var val =$("#id1"); //using id
var val = $(".cls"); //using classname
var val = $("p"); //using tag name
var val = $("p.cls"); //using selector