The page I created is to take Latitude & Longitude value input.
<div class="container ">
<form class="entry">
<div class="aligncenter">
<h5 style="color:MediumTurquoise; font-weight:100; font-family:'Oswald', sans-serif; letter-spacing: 0.1em;">Please enter the coordinate</h5>
<div>
<input type="number" min="0.0000000" max="999.9999999" id="lat" placeholder="Latitude">
<input type="number" min="0.0000000" max="999.9999999" id="long" placeholder="Longitude">
<button class="btn-rounded btn-normal btn-medium btn-primary" id="search" value="get Info">Submit</button>
</div>
</div>
</form>
</div>
Based on the input, i run a script using Jquery to display information from a REST API.
<script>
var data;
$(document).ready(function () {
$("#search").click(function () {
let lat = $("#lat").val();
let long =$("#long").val();
if (lat == "" || long == "") {
alert("please enter lat and long to get info");
return;
}
else {
document.getElementById('message').style.visibility = 'hidden';
document.getElementById('note').style.visibility = 'visible';
$('#note').show();
$('.show-onclick').show();
$.ajax({
type: "GET",
url: `https://rest.soilgrids.org/query?lon=${long}&lat=${lat}&attributes=ORCDRC,PHIHOX,PHIKCL,BLDFIE,CLYPPT,SLTPPT,SNDPPT,WWP`,
dataType: "json",
success: function (response) {
console.log(response);
var phihoxsl1 = response.properties.PHIHOX.M.sl1;
var phihoxsl2 = response.properties.PHIHOX.M.sl2;
var phihoxsl3 = response.properties.PHIHOX.M.sl3;
var phihoxsl4 = response.properties.PHIHOX.M.sl4;
var phihoxsl5 = response.properties.PHIHOX.M.sl5;
var phihoxsl6 = response.properties.PHIHOX.M.sl6;
var phihoxsl7 = response.properties.PHIHOX.M.sl7;
document.getElementById('phihoxsl1').innerHTML = "SL1 = " + phihoxsl1;
document.getElementById('phihoxsl2').innerHTML = "SL2 = " + phihoxsl2;
document.getElementById('phihoxsl3').innerHTML = "SL3 = " + phihoxsl3;
document.getElementById('phihoxsl4').innerHTML = "SL4 = " + phihoxsl4;
document.getElementById('phihoxsl5').innerHTML = "SL5 = " + phihoxsl5;
document.getElementById('phihoxsl6').innerHTML = "SL6 = " + phihoxsl6;
document.getElementById('phihoxsl7').innerHTML = "SL7 = " + phihoxsl7;
var phikclsl1 = response.properties.PHIKCL.M.sl1;
var phikclsl2 = response.properties.PHIKCL.M.sl2;
var phikclsl3 = response.properties.PHIKCL.M.sl3;
var phikclsl4 = response.properties.PHIKCL.M.sl4;
var phikclsl5 = response.properties.PHIKCL.M.sl5;
var phikclsl6 = response.properties.PHIKCL.M.sl6;
var phikclsl7 = response.properties.PHIKCL.M.sl7;
document.getElementById('phikclsl1').innerHTML = "SL1 = " + phikclsl1;
document.getElementById('phikclsl2').innerHTML = "SL2 = " + phikclsl2;
document.getElementById('phikclsl3').innerHTML = "SL3 = " + phikclsl3;
document.getElementById('phikclsl4').innerHTML = "SL4 = " + phikclsl4;
document.getElementById('phikclsl5').innerHTML = "SL5 = " + phikclsl5;
document.getElementById('phikclsl6').innerHTML = "SL6 = " + phikclsl6;
document.getElementById('phikclsl7').innerHTML = "SL7 = " + phikclsl7;
var orcdrcsl1 = response.properties.ORCDRC.M.sl1;
var orcdrcsl2 = response.properties.ORCDRC.M.sl2;
var orcdrcsl3 = response.properties.ORCDRC.M.sl3;
var orcdrcsl4 = response.properties.ORCDRC.M.sl4;
var orcdrcsl5 = response.properties.ORCDRC.M.sl5;
var orcdrcsl6 = response.properties.ORCDRC.M.sl6;
var orcdrcsl7 = response.properties.ORCDRC.M.sl7;
document.getElementById('orcdrcsl1').innerHTML = "SL1 = " + orcdrcsl1;
document.getElementById('orcdrcsl2').innerHTML = "SL2 = " + orcdrcsl2;
document.getElementById('orcdrcsl3').innerHTML = "SL3 = " + orcdrcsl3;
document.getElementById('orcdrcsl4').innerHTML = "SL4 = " + orcdrcsl4;
document.getElementById('orcdrcsl5').innerHTML = "SL5 = " + orcdrcsl5;
document.getElementById('orcdrcsl6').innerHTML = "SL6 = " + orcdrcsl6;
document.getElementById('orcdrcsl7').innerHTML = "SL7 = " + orcdrcsl7;
var wwpsl1 = response.properties.WWP.M.sl1;
var wwpsl2 = response.properties.WWP.M.sl2;
var wwpsl3 = response.properties.WWP.M.sl3;
var wwpsl4 = response.properties.WWP.M.sl4;
var wwpsl5 = response.properties.WWP.M.sl5;
var wwpsl6 = response.properties.WWP.M.sl6;
var wwpsl7 = response.properties.WWP.M.sl7;
document.getElementById('wwpsl1').innerHTML = "SL1 = " + wwpsl1;
document.getElementById('wwpsl2').innerHTML = "SL2 = " + wwpsl2;
document.getElementById('wwpsl3').innerHTML = "SL3 = " + wwpsl3;
document.getElementById('wwpsl4').innerHTML = "SL4 = " + wwpsl4;
document.getElementById('wwpsl5').innerHTML = "SL5 = " + wwpsl5;
document.getElementById('wwpsl6').innerHTML = "SL6 = " + wwpsl6;
document.getElementById('wwpsl7').innerHTML = "SL7 = " + wwpsl7;
var bldfiesl1 = response.properties.BLDFIE.M.sl1;
var bldfiesl2 = response.properties.BLDFIE.M.sl2;
var bldfiesl3 = response.properties.BLDFIE.M.sl3;
var bldfiesl4 = response.properties.BLDFIE.M.sl4;
var bldfiesl5 = response.properties.BLDFIE.M.sl5;
var bldfiesl6 = response.properties.BLDFIE.M.sl6;
var bldfiesl7 = response.properties.BLDFIE.M.sl7;
document.getElementById('bldfiesl1').innerHTML = "SL1 = " + bldfiesl1;
document.getElementById('bldfiesl2').innerHTML = "SL2 = " + bldfiesl2;
document.getElementById('bldfiesl3').innerHTML = "SL3 = " + bldfiesl3;
document.getElementById('bldfiesl4').innerHTML = "SL4 = " + bldfiesl4;
document.getElementById('bldfiesl5').innerHTML = "SL5 = " + bldfiesl5;
document.getElementById('bldfiesl6').innerHTML = "SL6 = " + bldfiesl6;
document.getElementById('bldfiesl7').innerHTML = "SL7 = " + bldfiesl7;
var clypptsl1 = response.properties.CLYPPT.M.sl1;
var clypptsl2 = response.properties.CLYPPT.M.sl2;
var clypptsl3 = response.properties.CLYPPT.M.sl3;
var clypptsl4 = response.properties.CLYPPT.M.sl4;
var clypptsl5 = response.properties.CLYPPT.M.sl5;
var clypptsl6 = response.properties.CLYPPT.M.sl6;
var clypptsl7 = response.properties.CLYPPT.M.sl7;
document.getElementById('clypptsl1').innerHTML = "SL1 = " + clypptsl1;
document.getElementById('clypptsl2').innerHTML = "SL2 = " + clypptsl2;
document.getElementById('clypptsl3').innerHTML = "SL3 = " + clypptsl3;
document.getElementById('clypptsl4').innerHTML = "SL4 = " + clypptsl4;
document.getElementById('clypptsl5').innerHTML = "SL5 = " + clypptsl5;
document.getElementById('clypptsl6').innerHTML = "SL6 = " + clypptsl6;
document.getElementById('clypptsl7').innerHTML = "SL7 = " + clypptsl7;
var sltpptsl1 = response.properties.SLTPPT.M.sl1;
var sltpptsl2 = response.properties.SLTPPT.M.sl2;
var sltpptsl3 = response.properties.SLTPPT.M.sl3;
var sltpptsl4 = response.properties.SLTPPT.M.sl4;
var sltpptsl5 = response.properties.SLTPPT.M.sl5;
var sltpptsl6 = response.properties.SLTPPT.M.sl6;
var sltpptsl7 = response.properties.SLTPPT.M.sl7;
document.getElementById('sltpptsl1').innerHTML = "SL1 = " + sltpptsl1;
document.getElementById('sltpptsl2').innerHTML = "SL2 = " + sltpptsl2;
document.getElementById('sltpptsl3').innerHTML = "SL3 = " + sltpptsl3;
document.getElementById('sltpptsl4').innerHTML = "SL4 = " + sltpptsl4;
document.getElementById('sltpptsl5').innerHTML = "SL5 = " + sltpptsl5;
document.getElementById('sltpptsl6').innerHTML = "SL6 = " + sltpptsl6;
document.getElementById('sltpptsl7').innerHTML = "SL7 = " + sltpptsl7;
var sndpptsl1 = response.properties.SNDPPT.M.sl1;
var sndpptsl2 = response.properties.SNDPPT.M.sl2;
var sndpptsl3 = response.properties.SNDPPT.M.sl3;
var sndpptsl4 = response.properties.SNDPPT.M.sl4;
var sndpptsl5 = response.properties.SNDPPT.M.sl5;
var sndpptsl6 = response.properties.SNDPPT.M.sl6;
var sndpptsl7 = response.properties.SNDPPT.M.sl7;
document.getElementById('sndpptsl1').innerHTML = "SL1 = " + sndpptsl1;
document.getElementById('sndpptsl2').innerHTML = "SL2 = " + sndpptsl2;
document.getElementById('sndpptsl3').innerHTML = "SL3 = " + sndpptsl3;
document.getElementById('sndpptsl4').innerHTML = "SL4 = " + sndpptsl4;
document.getElementById('sndpptsl5').innerHTML = "SL5 = " + sndpptsl5;
document.getElementById('sndpptsl6').innerHTML = "SL6 = " + sndpptsl6;
document.getElementById('sndpptsl7').innerHTML = "SL7 = " + sndpptsl7;
},
error: function (error) {
console.log(error);
alert("No data found");
}
})
}
})
})
</script>
However, I am only able to display the information on the first search only. The page won't refresh and display new data after I enter new input. I thought it was because of the input type, but seems can't to be solved. The information does appeared in console though.
Try adding type="button" to your submit button.
A button element is typed button by default if it is not inside a form.
Inside a form, a button is typed submit which has the same behavior has <input type="submit" /> which validates the form and refresh the page.
So you can :
use your button outside any form without specifying any type attribute
use it inside a form specifying type="button"
$("#btn").click((evt) => {
console.log("lat="+$("#lat").val()+" long="+$("#long").val());
});
<input id="lat" type="text" />
<input id="long" type="text" />
<button id="btn">Submit</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Related
I'm using the following script to export Google Ads data from my account, but I am stuck with Google's pre-set date ranges and can't figure out how/if it's possible to jimmy these. Ideal date range would be year to date, with the report refreshing each day and adding on a fresh day's data, but would also be interested if we can get all time to work.
I'm a coding novice, so apologies in advance.
Script:
function main() {
var currentSetting = new Object();
currentSetting.ss = SPREADSHEET_URL;
// Read Settings Sheet
var settingsSheet = SpreadsheetApp.openByUrl(currentSetting.ss).getSheetByName(SETTINGS_SHEET_NAME);
var rows = settingsSheet.getDataRange();
var numRows = rows.getNumRows();
var numCols = rows.getNumColumns();
var values = rows.getValues();
var numSettingsRows = numRows - 1;
var sortString = "";
var filters = new Array();
for(var i = 0; i < numRows; i++) {
var row = values[i];
var settingName = row[0];
var settingOperator = row[1];
var settingValue = row[2];
var dataType = row[3];
debug(settingName + " " + settingOperator + " " + settingValue);
if(settingName.toLowerCase().indexOf("report type") != -1) {
var reportType = settingValue;
} else if(settingName.toLowerCase().indexOf("date range") != -1) {
var dateRange = settingValue;
} else if(settingName.toLowerCase().indexOf("sort order") != -1) {
var sortDirection = dataType || "DESC";
if(settingValue) var sortString = "ORDER BY " + settingValue + " " + sortDirection;
var sortColumnIndex = 1;
}else {
if(settingOperator && settingValue) {
if(dataType.toLowerCase().indexOf("long") != -1 || dataType.toLowerCase().indexOf("double") != -1 || dataType.toLowerCase().indexOf("money") != -1 || dataType.toLowerCase().indexOf("integer") != -1) {
var filter = settingName + " " + settingOperator + " " + settingValue;
} else {
if(settingValue.indexOf("'") != -1) {
var filter = settingName + " " + settingOperator + ' "' + settingValue + '"';
} else if(settingValue.indexOf("'") != -1) {
var filter = settingName + " " + settingOperator + " '" + settingValue + "'";
} else {
var filter = settingName + " " + settingOperator + " '" + settingValue + "'";
}
}
debug("filter: " + filter)
filters.push(filter);
}
}
}
// Process the report sheet and fill in the data
var reportSheet = SpreadsheetApp.openByUrl(currentSetting.ss).getSheetByName(REPORT_SHEET_NAME);
var rows = reportSheet.getDataRange();
var numRows = rows.getNumRows();
var numCols = rows.getNumColumns();
var values = rows.getValues();
var numSettingsRows = numRows - 1;
// Read Header Row and match names to settings
var headerNames = new Array();
var row = values[0];
for(var i = 0; i < numCols; i++) {
var value = row[i];
headerNames.push(value);
//debug(value);
}
if(reportType.toLowerCase().indexOf("performance") != -1) {
var dateString = ' DURING ' + dateRange;
} else {
var dateString = "";
}
if(filters.length) {
var query = 'SELECT ' + headerNames.join(",") + ' FROM ' + reportType + ' WHERE ' + filters.join(" AND ") + dateString + " " + sortString;
} else {
var query = 'SELECT ' + headerNames.join(",") + ' FROM ' + reportType + dateString + " " + sortString;
}
debug(query);
var report = AdWordsApp.report(query);
try {
report.exportToSheet(reportSheet);
var subject = "Your " + reportType + " for " + dateRange + " for " + AdWordsApp.currentAccount().getName() + " is ready";
var body = currentSetting.ss + "<br>You can now add this data to <a href='https://www.optmyzr.com'>Optmyzr</a> or another reporting system.";
MailApp.sendEmail(EMAIL_ADDRESSES, subject, body);
Logger.log("Your report is ready at " + currentSetting.ss);
Logger.log("You can include this in your scheduled Optmyzr reports or another reporting tool.");
} catch (e) {
debug("error: " + e);
}
}
function debug(text) {
if(DEBUG) Logger.log(text);
}
I've tried overwriting the data validation in the host spreadsheet, but think I need to amend the script itself also.
I made a CGPA-SGPA calculator and I cannot get the value with refresh.
When I refresh and check the value it get feed
but not getting value without refresh.
var credit_1001 = document.querySelector('#credit_1001')
var grade_1001 = document.querySelector('#grade_1001')
var credit_1002 = document.querySelector('#credit_1002')
var grade_1002 = document.querySelector('#grade_1002')
var credit_1003 = document.querySelector('#credit_1003')
var grade_1003 = document.querySelector('#grade_1003')
var credit_1004 = document.querySelector('#credit_1004')
var grade_1004 = document.querySelector('#grade_1004')
var credit_1008 = document.querySelector('#credit_1008')
var grade_1008 = document.querySelector('#grade_1008')
var credit_1009 = document.querySelector('#credit_1009')
var grade_1009 = document.querySelector('#grade_1009')
//btn and result S1
var btn_check = document.querySelector('#check_s1')
var result_s1 = document.querySelector('#result_s1')
//btn click S1
var total_s1_credit = parseInt(credit_1001.value) + parseInt(credit_1002.value) + parseInt(credit_1003.value) + parseInt(credit_1004.value) + parseInt(credit_1008.value) + parseInt(credit_1009.value)
var got_s1_marks = parseInt(credit_1001.value) * parseInt(grade_1001.value) + parseInt(credit_1002.value) * parseInt(grade_1002.value) + parseInt(credit_1003.value) * parseInt(grade_1003.value) + parseInt(credit_1004.value) * parseInt(grade_1004.value) + parseInt(credit_1008.value) * parseInt(grade_1008.value) + parseInt(credit_1009.value) * parseInt(grade_1009.value)
btn_check.addEventListener('click', () => {
result_s1.innerText = " S1 SGPA " + got_s1_marks / total_s1_credit
console.log("S1 Total Credit = " + total_s1_credit)
console.log("S1 Got Marks = " + got_s1_marks)
console.log("S1 SGPA = " + result_s1.innerText)
})
You need to get the values for your calculation inside of the click handler, right now you get them before the click, and then use (the old values) when the click happens
btn_check.addEventListener('click', () => {
//btn click S1
var total_s1_credit = parseInt(credit_1001.value) + parseInt(credit_1002.value) + parseInt(credit_1003.value) + parseInt(credit_1004.value) + parseInt(credit_1008.value) + parseInt(credit_1009.value)
var got_s1_marks = parseInt(credit_1001.value) * parseInt(grade_1001.value) + parseInt(credit_1002.value) * parseInt(grade_1002.value) + parseInt(credit_1003.value) * parseInt(grade_1003.value) + parseInt(credit_1004.value) * parseInt(grade_1004.value) + parseInt(credit_1008.value) * parseInt(grade_1008.value) + parseInt(credit_1009.value) * parseInt(grade_1009.value)
result_s1.innerText = " S1 SGPA " + got_s1_marks / total_s1_credit
console.log("S1 Total Credit = " + total_s1_credit)
console.log("S1 Got Marks = " + got_s1_marks)
console.log("S1 SGPA = " + result_s1.innerText)
})
I'm trying to POST to a google DB. When I submit the form, the database is populated. However, I don't receive any response back from the DB it seems.
I would like to receive a response, and if it is a success, I will navigate to a new web page.
<script type="text/javascript">
function myPOSTFunction() {
//Define Variables
var firstName = document.getElementsByName("firstName")[0].value;
var lastName = document.getElementsByName("lastName")[0].value;
var initial = document.getElementsByName("initial")[0].value;
var suffix = document.getElementsByName("suffix")[0].value;
var dob = document.getElementsByName("dob")[0].value;
var phoneNum = document.getElementsByName("phoneNumber")[0].value;
var emailAddress = document.getElementsByName("email")[0].value;
var streetAddress = document.getElementsByName("street")[0].value;
var aptNum = document.getElementsByName("apt")[0].value;
var municipality = document.getElementsByName("town")[0].value;
var state = document.getElementsByName("state")[0].value;
var zip = document.getElementsByName("zip")[0].value;
var mail_streetAddress = document.getElementsByName("mailStreet")[0].value;
var mail_apt = document.getElementsByName("mailApt")[0].value;
var mail_municipality = document.getElementsByName("mailTown")[0].value;
var mail_state = document.getElementsByName("mailState")[0].value;
var mail_zip = document.getElementsByName("mailZip")[0].value;
// var other_election = document.getElementsByName("other_election")[0].value;
// var other_votingDate = document.getElementsByName("other_votingDate")[0].value;
var electionType = document.getElementsByName('selection');
for (var i = 0, length = electionType.length; i < length; i++) {
if (electionType[i].checked) {
// do whatever you want with the checked radio
electionType = electionType[i].value;
// only one radio can be logically checked, don't check the rest
break;
}
}
const xhr = new XMLHttpRequest();
xhr.onload = function() {
const serverResponse = document.getElementById("serverResponse");
serverResponse.innerHTML = this.responseText;
}
xhr.open("POST", "https://us-central1-votebymail.cloudfunctions.net/create_voter");
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
var outputString =
'first_name=' + firstName +
'&last_name=' + lastName +
'&middle_name_or_initial=' + initial +
'&suffix=' + suffix +
'&dob=' + dob +
'&phone_number=' + phoneNum +
'&email_address=' + emailAddress +
'&lives_street_address=' + streetAddress +
'&lives_apartment_number=' + aptNum +
'&lives_municipality=' + municipality +
'&lives_state_abbreviation=' + state +
'&lives_zip_code=' + zip +
'&mail_to_street_address=' + mail_streetAddress +
'&mail_to_apartment_number=' + mail_apt +
'&mail_to_municipality=' + mail_municipality +
'&mail_to_state_abbreviation=' + mail_state +
'&mail_to_zip_code=' + mail_zip +
'&election_voting_in=' + electionType;
// '&other_election_voting_in=' + other_election +
// '&other_election_voting_In_date=' + other_votingDate;
xhr.send(outputString);
}
</script>
You need to have a response callback.
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.responseText);
//do something else with the response.
}
I have a problem with my code, i wanna see my passed 4 generated number (Math.random), on a history box, but these numbers show out the same. Is there a way to delay a var?
I have tried putting var in order, but this makes no delay.
my html:
<div class="text-position-history">
<div class="text-style-history">
<p id="historyT"></p>
</div>
</div>
</body>
</html>
My javascript:
var green = 0;
var red = 0;
function odds(){
var result = Math.random();
if (result < 0.5)
{
document.body.style.backgroundColor = "green";
green++;
document.getElementById('greenT').innerHTML = "Times you survived: " + " " + green;
}
else{
document.body.style.backgroundColor = "red";
red++;
document.getElementById('redT').innerHTML = "Times you died: " + " " + red;
}
document.getElementById('resultT').innerHTML = "Guessed number: " + " " + result;
var history1 = result;
var history2 = history1;
var history3 = history2;
document.getElementById('historyT').innerHTML = "Guessed number: " + " " + result + " " + history1 + " " + history2 + " " + history3;
}
Is there a way to do this?
Why don't you just create an array and then append the new values of result to the array after you call Math.random()?
var resultHistory = new Array();
var result = Math.random();
resultHistory.push(result);
Then print out the array later on.
Why not just use array of numbers?
var _history = [];
function toHTMLElement(historyNode)
{
var node = document.createElement("div");
node.innerHTML = historyNode.text;
node.style.background = historyNode.win?'green':'red';
return node;
}
function renderHistory()
{
var result = document.getElementById("result");
result.innerHTML = "";
_history.forEach(function(e){
result.appendChild(toHTMLElement(e));
});
}
document.getElementById("form").addEventListener("submit", function(e){
e.preventDefault();
_history.push((Math.random()>0.5)?{win: true, text: 'You win'}:{win: false, text: 'You lose'});
if (_history.length > 3) _history.shift();
renderHistory();
});
<form id="form">
<input type="submit">
</form>
<div id="result"></div>
var green = 0;
var red = 0;
function odds(){
var result = Math.random();
if (result < 0.5)
{
document.body.style.backgroundColor = "green";
green++;
document.getElementById('greenT').innerHTML = "Times you survived: " + " " + green;
}
else{
document.body.style.backgroundColor = "red";
red++;
document.getElementById('redT').innerHTML = "Times you died: " + " " + red;
}
document.getElementById('resultT').innerHTML = "Guessed number: " + " " + result;
var myList = [result, result, result];
var history1 = myList.shift();
var history2 = myList.shift();
var history3 = myList.shift();
document.getElementById('historyT').innerHTML = "Guessed numbesr: " + " " + history1 + " " + history2 + " " + history3;
}
This still gives the same result?
I think actually changing the order of your history vars should fix it.
Change them to
var history3 = history2;
var history2 = history1;
var history1 = result;
Right now you are overwritung everything to results because:
var history1 = result
var history2 = history1 (history1 is already referring to result by now)
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I'm running a web page in Safar, however; I notice that when I press the save button the event doesn't fire. It works fine in IE though. I've researched the issue, and found that it's not due to a missing value attribute or single/double quote specifics. Any help would be appreciated.
<input type='button' name='Save' id='saveCut' value='Save Cut' class=button onClick=\"Puma.saveTheCut()\">
JS function
Puma.saveTheCut = function () {
var offerId = inStoreCut.cutOfferFields[0];
var merchId = inStoreCut.cutOfferFields[1];
var adId = inStoreCut.cutOfferFields[2];
var eventID = inStoreCut.cutOfferFields[3];
var adNum = inStoreCut.cutOfferFields[4];
var cutID = inStoreCut.cutOfferFields[5];
var merchDescription = parent.main.document.getElementById('merchDescription').value;
var UPC = parent.main.document.getElementById('merchUPC').value;
var nrfSampleColorObj = parent.main.document.getElementById('itemColor');
var nrfSampleColor = nrfSampleColorObj.options[nrfSampleColorObj.selectedIndex].value;
var nrfsampleSubColorObj = parent.main.document.getElementById('itemChildColor');
var colorCodeStr = nrfsampleSubColorObj.options[nrfsampleSubColorObj.selectedIndex].value;
var nrfsampleSubColor = colorCodeStr.substring(0, 3);
var customer_Facing_Color = parent.main.document.getElementById('merchCustomerFacingColor').value;
var division = parent.main.document.getElementById('merchFob').value;
var deptNum = parent.main.document.getElementById('merchDept0~0').value;
var vendorNum = parent.main.document.getElementById('merchVendorNum0~0').value;
var pID = parent.main.document.getElementById('pID0~0').value;
var regPrice = parent.main.document.getElementById('regPrice').value;
var sampleSize = parent.main.document.getElementById('itemSize').value;
var itemQty = parent.main.document.getElementById('itemQty').value;
if (parent.main.document.getElementById('chkMerchSet').checked) {
var set = "1";
}
else {
var set = "0";
}
var sampleTypeObj = parent.main.document.getElementById("itemType");
var sampleType = sampleTypeObj.options[sampleTypeObj.selectedIndex].text;
var merchColorCorrObj = parent.main.document.getElementById("merchColorCorr");
var colorCorr = merchColorCorrObj.options[merchColorCorrObj.selectedIndex].value;
var merchSwatchObj = parent.main.document.getElementById("merchSwatch");
var Swatch = merchSwatchObj.options[merchSwatchObj.selectedIndex].value;
var pantoneColor = parent.main.document.getElementById('merchPantone').value;
var photoStylingDetails = parent.main.document.getElementById('merchPhotoStylingDetails').value;
var mCOMSampleId = parent.main.document.getElementById('mCOMSample').value;
var deptName = parent.main.document.getElementById('merchDeptName0~0').innerHTML;
var vendorName = Puma.decoder(parent.main.document.getElementById('merchVendorName0~0').innerHTML);
if (parent.main.document.getElementById('pidStatus0~0').value == "NOT IN PD") {
var pidStatus = "0";
}
else {
var pidStatus = "1";
}
var pidDescription = parent.main.document.getElementById('pidDescription').value;
var webId = parent.main.document.getElementById('webID0~0').innerHTML;
var vStyle = parent.main.document.getElementById('merchVStyle').value;
var markStyle = parent.main.document.getElementById('merchMarkStyle').value;
var subClass = parent.main.document.getElementById('Subclass').value;
// var productDescription = parent.main.document.getElementById('productDescription').value;
var docLineitemNum = parent.main.document.getElementById('merchDoc').value;
var merchTurnInStatusObj = parent.main.document.getElementById("merchTurnInStatus");
var turnInStatus = merchTurnInStatusObj.options[merchTurnInStatusObj.selectedIndex].text;
var reason = parent.main.document.getElementById('merchReason').value;
var merchCountryOriginObj = parent.main.document.getElementById("countryOfOrigin");
var countryOfOrigin = merchCountryOriginObj.options[merchCountryOriginObj.selectedIndex].value;
var importedCountry = parent.main.document.getElementById("importedCountries").value;
//var importedCountry = merchImportedCountryObj.options[merchImportedCountryObj.selectedIndex].text;
var fabricContent = parent.main.document.getElementById("fabricContent").value;
var careInstructions = parent.main.document.getElementById("careInstructions").value;
var offerDescription = parent.main.document.getElementById("offerDescription").value;
var onlyAtMacysObj = parent.main.document.getElementById("onlyAtMacys");
var onlyAtMacysValue = parseInt(onlyAtMacysObj.options[onlyAtMacysObj.selectedIndex].value, 10);
var onlyAtMacys = onlyAtMacysValue;
var legalOneObj = parent.main.document.getElementById("legalOne");
var legalOne = legalOneObj.options[legalOneObj.selectedIndex].value;
var legalOneExplain = parent.main.document.getElementById("explainLegalOne").value;
var legalTwoObj = parent.main.document.getElementById("legalTwo");
var legalTwo = legalTwoObj.options[legalTwoObj.selectedIndex].value;
var legalTwoExplain = parent.main.document.getElementById("explainLegalTwo").value;
var legalThreeObj = parent.main.document.getElementById("legalThree");
var legalThree = legalThreeObj.options[legalThreeObj.selectedIndex].value;
var legalThreeExplain = parent.main.document.getElementById("explainLegalThree").value;
var legalFourObj = parent.main.document.getElementById("legalFour");
var legalFour = legalFourObj.options[legalFourObj.selectedIndex].value;
var fiftyObj = parent.main.document.getElementById("overFifty");
var fifty = fiftyObj.options[fiftyObj.selectedIndex].value;
var userId = parent.botnav.uinfo.userID;
if (Puma.btiRequiredFieldIsValidated() == true) {
if (inStoreCut.existingRecord == false) {
sql = "action=saveMerchFormForCut&cutID=" + cutID +
//sql = "action=updateMerchFormForCut&cutID=" + cutID +
"&merchDescription=" + encodeURIComponent(merchDescription) +
"&UPC=" + UPC +
"&nrfSampleColor=" + nrfSampleColor +
"&nrfSampleSubColor=" + nrfsampleSubColor +
"&division=" + encodeURIComponent(division) +
"&deptNum=" + deptNum +
"&merchVendorNum=" + vendorNum +
"&pID=" + pID +
"&Customer_Facing_Color=" + encodeURIComponent(customer_Facing_Color) +
"®Price=" + regPrice +
"&sampleSize=" + encodeURIComponent(sampleSize) +
"&itemQty=" + itemQty +
"&set=" + set +
"&sampleType=" + sampleType +
"&colorCorr=" + colorCorr +
"&Swatch=" + Swatch +
"&pantoneColor=" + encodeURIComponent(pantoneColor) +
"&photoStylingDetails=" + encodeURIComponent(photoStylingDetails) +
"&mCOMSampleId=" + mCOMSampleId +
"&deptName=" + deptName +
"&vendorName=" + encodeURIComponent(vendorName) +
"&pidStatus=" + pidStatus +
"&pidDescription=" + pidDescription +
"&webId=" + webId +
"&vStyle=" + vStyle +
"&markStyle=" + markStyle +
"&subClass=" + subClass +
"&docLineItemNum=" + docLineitemNum +
"&merchTurnInStatus=" + turnInStatus +
"&reason=" + encodeURIComponent(reason) +
"&countryOfOrigin=" + countryOfOrigin +
"&importedCountry=" + importedCountry +
"&fabricContent=" + encodeURIComponent(fabricContent) +
"&careInstructions=" + encodeURIComponent(careInstructions) +
"&offerDescription=" + encodeURIComponent(offerDescription) +
"&onlyAtMacys=" + onlyAtMacys +
"&legalOne=" + legalOne +
"&legalOneExplain=" + legalOneExplain +
"&legalTwo=" + legalTwo +
"&legalTwoExplain=" + legalTwoExplain +
"&legalThree=" + legalThree +
"&legalThreeExplain=" + legalThree +
"&legalFour=" + legalFour +
"&fifty=" + fifty +
"&createdBy=" + userId
var ajaxMaster = new AjaxMaster(sql, "Puma.saveMerchFormForCutData(data)", "", "btiDispatcher.aspx");
sql = "action=updateMerchFormForCut&sql=" + encodeURIComponent(msql);
objAjaxAd.main_flag = "updateMerchFormForCut";
objAjaxAd.SendQuery(sql);
// "[t0].[signedByUserID]," +
// "[t0].[signedStatus]," +
//"[t0].[dateSigned]," +
//"[t0].[signedLastByUserID]," +
//"[t0].[dateLastSigned1]," +
//"[t0].[signedLastStatus]" +
// var ajaxMaster = new AjaxMaster(sql, "Puma.updateMerchFormForCutData(data)", "", "puma_core.aspx");
}
else {
sql = "action=updateMerchFormForCut&cutID=" + cutID +
"&offerId" + offerId +
"&merchId" + merchId +
"&adID" + adId +
"&eventID" + eventID +
"&adNum" + adNum +
"&merchDescription=" + encodeURIComponent(merchDescription) +
"&UPC=" + UPC +
"&nrfSampleColor=" + nrfSampleColor +
"&nrfSampleSubColor=" + nrfsampleSubColor +
"&division=" + encodeURIComponent(division) +
"&deptNum=" + deptNum +
"&merchVendorNum=" + vendorNum +
"&pID=" + pID +
"&Customer_Facing_Color=" + encodeURIComponent(customer_Facing_Color) +
"®Price=" + regPrice +
"&sampleSize=" + encodeURIComponent(sampleSize) +
"&itemQty=" + itemQty +
"&set=" + set +
"&sampleType=" + sampleType +
"&colorCorr=" + colorCorr +
"&Swatch=" + Swatch +
"&pantoneColor=" + encodeURIComponent(pantoneColor) +
"&photoStylingDetails=" + encodeURIComponent(photoStylingDetails) +
"&mCOMSampleId=" + mCOMSampleId +
"&deptName=" + deptName +
"&vendorName=" + encodeURIComponent(vendorName) +
"&pidStatus=" + pidStatus +
"&pidDescription=" + pidDescription +
"&webId=" + webId +
"&vStyle=" + vStyle +
"&markStyle=" + markStyle +
"&subClass=" + subClass +
"&docLineItemNum=" + docLineitemNum +
"&merchTurnInStatus=" + turnInStatus +
"&reason=" + encodeURIComponent(reason) +
"&countryOfOrigin=" + countryOfOrigin +
"&importedCountry=" + importedCountry +
"&fabricContent=" + encodeURIComponent(fabricContent) +
"&careInstructions=" + encodeURIComponent(careInstructions) +
"&offerDescription=" + encodeURIComponent(offerDescription) +
"&onlyAtMacys=" + onlyAtMacys +
"&legalOne=" + legalOne +
"&legalOneExplain=" + legalOneExplain +
"&legalTwo=" + legalTwo +
"&legalTwoExplain=" + legalTwoExplain +
"&legalThree=" + legalThree +
"&legalThreeExplain=" + legalThree +
"&legalFour=" + legalFour +
"&fifty=" + fifty +
//"&createdBy=" + userId
"&offerId=" + offerId +
"&merchId=" + merchId +
"&adID=" + adId +
"&eventID=" + eventID +
"&adNum=" + adNum
var ajaxMaster = new AjaxMaster(sql, "Puma.updateMerchFormForCutData(data)", "", "btiDispatcher.aspx");
sql = "action=updateMerchFormForCut&sql=" + encodeURIComponent(msql);
//objAjaxAd.SendQuery(sql);
// "[t0].[signedByUserID]," +
// "[t0].[signedStatus]," +
//"[t0].[dateSigned]," +
//"[t0].[signedLastByUserID]," +
//"[t0].[dateLastSigned1]," +
//"[t0].[signedLastStatus]" +
objAjaxAd.main_flag = "updateMerchFormForCutData";
objAjaxAd.SendQuery(sql);
//var ajaxMaster = new AjaxMaster(sql, "Puma.updateMerchFormForCutData(data)", "", "puma_core.aspx");
}
}
}
Write just " and not \" in the onClick attribute, or just omit the quotation marks:
onClick=Puma.saveTheCut()
The character \ has no special role in HTML; it’s just yet another character. So when you have onClick=\"Puma.saveTheCut()\", the actual attribute value is \"Puma.saveTheCut()\", which does not work of course, as you can see by looking at the console in the Developer Tools of your browser. You should see something the like following there:
SyntaxError: illegal character
\"Puma.saveTheCut()\"
(or with \"yup()\" when testing Agony’s jsfiddle).
As it is, the code should not work in any browser, and does not work in my IE 10 either.