|
POST
|
I have these two functions which both work, but I would like to cut it down to one if possible. They populate dropdown lists on two forms. Any thoughts on how to change this to one function?: // Begin populateSupportSelect
function populateSupportSelect(x, y) {
//get the domain value
var domain = app.supportLayer.getDomain(x);
//get the html select by ID
var select = document.getElementById(y);
//clear the current options in select
for (var option in select) {
select.remove(option);
}
var opt = document.createElement('option');
opt.innerHTML = "";
select.appendChild(opt);
//loop through the domain value to fill the drop down
for (var i = 0; i < domain.codedValues.length; i++) {
console.log(domain.codedValues.name);
; var opt = document.createElement('option');
opt.innerHTML = domain.codedValues.name;
opt.value = domain.codedValues.name;
select.appendChild(opt);
}
}
// End populateSupportSelect
// Begin populateSelect
function populateSelect(x, y) {
//get the domain value
var domain = app.signLayer.getDomain(x);
//get the html select by ID
var select = document.getElementById(y);
//clear the current options in select
for (var option in select) {
select.remove(option);
}
var opt = document.createElement('option');
opt.innerHTML = "";
select.appendChild(opt);
//loop through the domain value to fill the drop down
for (var i = 0; i < domain.codedValues.length; i++) {
console.log(domain.codedValues.name);
; var opt = document.createElement('option');
opt.innerHTML = domain.codedValues.name;
opt.value = domain.codedValues.name;
select.appendChild(opt);
}
}
// End populateSelect Here is how I populate the dropdown lists: /* Enter your domain item and then the element to populate */
populateSelect("BACKING", "backing");
populateSelect("VISIBILITY", "visibility");
populateSelect("CONDITION_", "condition");
populateSelect("COLOR1", "color1");
populateSelect("DELINEATOR", "delineator");
populateSelect("ILLUM", "illum");
populateSelect("ATTACHTYPE", "attachType");
populateSelect("ATTACHLOC", "attachLoc");
populateSelect("SITEOBS", "siteObs");
populateSelect("SIGNSHAPE", "signShape");
populateSelect("COLOR2", "color2");
populateSelect("MUTCD", "mutcd");
/* Show supports form */
} else if (severity === "1") {
app.attributesModal.modal("show");
/* Enter your domain item and then the element to populate */
populateSupportSelect("TYPE", "type");
populateSupportSelect("SIZE_", "size");
populateSupportSelect("MATERIAL", "material");
populateSupportSelect("BASE", "base");
populateSupportSelect("RATING", "rating");
}
... View more
05-15-2015
09:05 AM
|
0
|
9
|
4933
|
|
POST
|
Thank you. Tom Wayson also found me this: HTML DOM Form reset() Method I thought it had to be of a button type.
... View more
05-14-2015
02:52 PM
|
1
|
0
|
1657
|
|
POST
|
I have a form that I am using to add or edit points to a map. Is there a way on start up to clear the form of any pre-existing data on load? Here is my form: <div id="attributesSignModal" class="modal fade" style="display: none;" aria-hidden="true">
<!-- Modal Dialog Begin -->
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Add/Edit Sign</h4>
</div>
<div class="modal-body">
<!-- Installed Begin -->
<div class="form-group">
<label for="installed">Installed</label>
<input type="date" class="form-control" name="installed" id="installed" />
</div>
<!-- Installed End -->
<!-- Sign ID Begin -->
<div class="form-group">
<label for="signId">Sign ID</label>
<input type="number" class="form-control" placeholder="Sign ID" name="signId" id="signId" />
</div>
<!-- Sign ID End -->
<!-- Facing Begin -->
<div class="form-group">
<label for="facing">Facing</label>
<input type="text" class="form-control" placeholder="Facing" name="facing" id="facing" />
</div>
<!-- Facing End -->
<!-- Visibility Begin -->
<div class="form-group">
<label for="visibility">Visibility</label>
<select id="visibility" class="form-control" name="visibility">
</select>
</div>
<!-- Visibility End -->
<!-- Condition Begin -->
<div class="form-group">
<label for="condition">Condition</label>
<select id="condition" class="form-control" name="visibility">
</select>
</div>
<!-- Condition End -->
<!-- Support ID Begin -->
<div class="form-group">
<label for="supportId">Support ID</label>
<input type="number" class="form-control" name="supportId" id="supportId" />
</div>
<!-- Support ID End -->
<!-- Text Begin -->
<div class="form-group">
<label for="text">Text</label>
<input type="text" class="form-control" name="text" id="text" />
</div>
<!-- Text End -->
<!-- Color 1 Begin -->
<div class="form-group">
<label for="color1">Color 1</label>
<select id="color1" class="form-control" name="color1" required>
</select>
</div>
<!-- Color 1 End -->
<!-- Delineator Begin -->
<div class="form-group">
<label for="delineator">Delineator</label>
<select id="delineator" class="form-control" name="delineator">
</select>
</div>
<!-- Delineator End -->
<!-- Illum Begin -->
<div class="form-group">
<label for="illum">Illum</label>
<select id="illum" class="form-control" name="illum">
</select>
</div>
<!-- Illum End-->
<!-- Offset Begin -->
<div class="form-group">
<label for="offset">Offset</label>
<input type="text" class="form-control" name="offset" id="offset" />
</div>
<!-- Offset Ends -->
<!-- Mountht Begin -->
<div class="form-group">
<label for="mountht">MOUNTHT</label>
<input type="text" class="form-control" name="mountht" id="mountht"/>
</div>
<!-- Mountht End -->
<!-- Backing Begin -->
<div class="form-group">
<label for="backing">Backing</label>
<select id="backing" class="form-control" name="backing">
</select>
</div>
<!-- Backing End -->
<!-- Width Begin -->
<div class="form-group">
<label for="width">Width</label>
<input type="text" class="form-control" name="width" id="width" />
</div>
<!-- Width End -->
<!-- Height Begin -->
<div class="form-group">
<label for="height">Height</label>
<input type="text" class="form-control" name="height" id="height"/>
</div>
<!-- Height End -->
<!-- Txt Size Begin -->
<div class="form-group">
<label for="txtSize">Text Size</label>
<input type="text" class="form-control" name="txtSize" id="txtSize"/>
</div>
<!-- Txt Size End -->
<!-- Num Size Begin -->
<div class="form-group">
<label for="numSize">Numsize</label>
<input type="text" class="form-control" name="numSize" id="numSize"/>
</div>
<!-- Num Size End -->
<!-- Comments Begin -->
<div class="form-group">
<label for="comments">Comments</label>
<input type="text" class="form-control" name="comments" id="comments"/>
</div>
<!-- Comments End -->
<!-- Two Sided Begin -->
<div class="form-group">
<label for="twoSided">Two Sided</label>
<input type="text" class="form-control" name="twoSided" id="twoSided" />
</div>
<!-- Two Sided End -->
<!-- Attach Type Begin -->
<div class="form-group">
<label for="attachType">Attach Type</label>
<select id="attachType" class="form-control" name="attachType">
</select>
</div>
<!-- Attach Type End -->
<!-- Attach Num Begin -->
<div class="form-group">
<label for="attachNum">Attach Num</label>
<input type="text" class="form-control" name="attachNum" id="attachNum"/>
</div>
<!-- Attach Num End -->
<!-- Attach Loc Begin -->
<div class="form-group">
<label for="attachLoc">Attach Loc</label>
<select id="attachLoc" class="form-control" name="attachLoc">
</select>
</div>
<!-- Attach Loc End -->
<!-- siteObs Begin -->
<div class="form-group">
<label for="siteObs">Siteobs</label>
<select id="siteObs" class="form-control" name="siteObs">
</select>
</div>
<!-- siteObs End -->
<!-- Sign Shape Begin -->
<div class="form-group">
<label for="signShape">Sign Shape</label>
<select id="signShape" class="form-control" name="signShape">
</select>
</div>
<!-- Sign Shape End -->
<!-- Color 2 Begin -->
<div class="form-group">
<label for="color2">Color 2</label>
<select id="color2" class="form-control" name="color2">
</select>
</div>
<!-- Color 2 End -->
<!-- Mutcd Begin -->
<div class="form-group">
<label for="mutcd">MUTCD</label>
<select id="mutcd" class="form-control" name="mutcd">
</select>
</div>
<!-- Mutcd End -->
<button class="btn btn-success">Submit</button>
<button class="btn btn-default">Cancel</button>
<button id="btnPrevious" class="btn navButton" style="visibility:hidden">Previous</button>
<button id="btnNext" class="btn navButton" style="visibility:hidden">Next</button>
</div>
</div>
</div>
<!-- Modal Dialog End -->
</div>
... View more
05-14-2015
02:33 PM
|
0
|
3
|
4990
|
|
POST
|
I usually wing it when I use GitHub, but wanted to share with anyone interested that SitePoint has an online class for Git: Introduction to Git - Learnable My area of concern is Git Pull requests and it covers that. It's not free, but I have found SitePoint.com an excellent resource. Feel free to add links on Git training, especially free ones.
... View more
05-14-2015
11:32 AM
|
0
|
0
|
3748
|
|
POST
|
If an application is having a problem, I would like to allow the user to create a screen print on a mobile device, like an iPad and then send the image as an attachment using JavaScript. How do you do this?
... View more
05-14-2015
08:51 AM
|
0
|
2
|
3488
|
|
POST
|
Awesome. It did need a trailing parenthesis and restEndPoint to be declared still, but you knocked out four variables for me. Thanks! Here is my updated code for anyone that needs it: var restEndPoint = "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/";
// app configuration
var config = {
mapOptions: {
showAttribution: false,
sliderStyle: "small",
extent: initialExtent,
logo: false,
sliderPosition: "bottom-right"
},
signLayerUrl: undefined,
supportLayerUrl: undefined
};
// Get the id of a layer
var requestHandle = esriRequest({
url: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/",
content: { f: 'json' },
handleAs: "json"
});
requestHandle.then(function (lyrJSON, io) {
for (var i = 0; i < lyrJSON.layers.length; i++) {
if (lyrJSON.layers.name == "Support") {
config.supportLayerUrl = restEndPoint + lyrJSON.layers.id;
}
if (lyrJSON.layers.name == "Sign") {
config.signLayerUrl = restEndPoint + lyrJSON.layers.id;
}
}
initMap();
})
... View more
05-14-2015
08:43 AM
|
0
|
2
|
1791
|
|
POST
|
Thanks. I was evaluating the assignment. Felt stupid. Works great.
... View more
05-13-2015
02:37 PM
|
0
|
0
|
1791
|
|
POST
|
I am trying to loop through layers and this block of code works: var jsonValue, signUrl, supportUrl;
var restEndPoint = "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/";
var config;
// Get the id of a layer
var requestHandle = esriRequest({
url: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/",
content: {
f: 'json'
},
handleAs: "json"
});
requestHandle.then(function (lyrJSON, io) {
for (var i = 0; i < lyrJSON.layers.length; i++) {
if (lyrJSON.layers.name = "Support") {
jsonValue = lyrJSON.layers.id;
supportUrl = restEndPoint + jsonValue;
}
}
// app configuration
config = {
mapOptions: {
showAttribution: false,
sliderStyle: "small",
extent: initialExtent,
logo: false,
sliderPosition: "bottom-right"
},
signLayerUrl: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/0",
supportLayerUrl: supportUrl
};
initMap();
}) But when I try to add the following code, I can't assign the value to signLayerUrl. I even tried to change i to t for the second if statement: var signValue, signUrl, supportValue, supportUrl;
var restEndPoint = "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/";
var config;
// Get the id of a layer
var requestHandle = esriRequest({
url: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/",
content: {
f: 'json'
},
handleAs: "json"
});
requestHandle.then(function (lyrJSON, io) {
for (var i = 0; i < lyrJSON.layers.length; i++) {
if (lyrJSON.layers.name = "Support") {
supportValue = lyrJSON.layers.id;
supportUrl = restEndPoint + supportValue;
}
if (lyrJSON.layers.name = "Sign") {
signValue = lyrJSON.layers.id;
signUrl = restEndPoint + signValue;
}
}
// app configuration
config = {
mapOptions: {
showAttribution: false,
sliderStyle: "small",
extent: initialExtent,
logo: false,
sliderPosition: "bottom-right"
},
signLayerUrl: signUrl,
supportLayerUrl: supportUrl
};
initMap();
})
... View more
05-13-2015
02:21 PM
|
0
|
6
|
5246
|
|
POST
|
I had not thought of that. I can just put the return value in a hidden element on my web page and then set the value to that in code. Thanks!
... View more
05-13-2015
07:43 AM
|
0
|
0
|
1027
|
|
POST
|
I have the following code and the script evaluate which layer is Support. In this case it is one. I would like to assign that value through JavaScript as opposed to hard coding it. jsonValue does give me what I want, but I can't figure out how to assign the number to the supportLayerUrl: var jsonValue;
// Get the id of a layer
var requestHandle = esriRequest({
url: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/",
content: {
f: 'json'
},
handleAs: "json"
});
requestHandle.then(function (lyrJSON, io) {
for (var i = 0; i < lyrJSON.layers.length; i++) {
if (lyrJSON.layers.name = "Support") {
jsonValue = lyrJSON.layers.id;
}
}
return jsonValue;
})
function checkValue() {
alert(jsonValue);
}
// app configuration
var config = {
mapOptions: {
showAttribution: false,
sliderStyle: "small",
extent: initialExtent,
logo: false,
sliderPosition: "bottom-right"
},
signLayerUrl: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/0",
supportLayerUrl: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/1"
}; I would like for my supportLayerUrl be something like this: supportLayerUrl: "http://maps.decaturil.gov/arcgis/rest/services/test/StreetSignTest/FeatureServer/" + jsonValue But I get jsonValue not defined. Any ideas?
... View more
05-12-2015
02:59 PM
|
0
|
2
|
4381
|
|
POST
|
To evaluate if a layer if any web services are not running, you would enter the following code: app.map.on("layer-add-result", function (evt) {
console.log(evt);
var testValue = evt.layer.valueOf();
if (testValue._div == null) {
/* Page Redirect */
window.location.assign("http://www.w3schools.com")
}
}); You may not need app for your application.
... View more
05-12-2015
02:51 PM
|
2
|
0
|
1111
|
|
POST
|
This question was answered through Esri support. To obtain the coded values to populate a dropdown list, you enter the following code. I included an additional line so that no option would appear to be selected when a dropdown first appears. //get the domain value
var domain = app.signLayer.getDomain("BACKING");
//get the html select by ID
var select = document.getElementById("backing");
//clear the current options in select
for (var option in select) {
select.remove(option);
}
var opt = document.createElement('option');
opt.innerHTML = "";
select.appendChild(opt);
//loop through the domain value to fill the drop down
for (var i = 0; i < domain.codedValues.length; i++) {
console.log(domain.codedValues.name);
;var opt = document.createElement('option');
opt.innerHTML = domain.codedValues.name;
opt.value = domain.codedValues.name;
select.appendChild(opt);
} To go a little further with this, you could create a function with arguments like so: function populateSelect(x, y) {
//get the domain value
var domain = app.signLayer.getDomain(x);
//get the html select by ID
var select = document.getElementById(y);
//clear the current options in select
for (var option in select) {
select.remove(option);
}
var opt = document.createElement('option');
opt.innerHTML = "";
select.appendChild(opt);
//loop through the domain value to fill the drop down
for (var i = 0; i < domain.codedValues.length; i++) {
console.log(domain.codedValues.name);
; var opt = document.createElement('option');
opt.innerHTML = domain.codedValues.name;
opt.value = domain.codedValues.name;
select.appendChild(opt);
}
} And then for each dropdown that you want to populate, you could enter this line of code and replace the values for each line. populateSelect("BACKING", "backing"); This will save you around 15 lines of code for each dropdown list that you want to populate.
... View more
05-12-2015
09:13 AM
|
1
|
0
|
1695
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-26-2015 12:31 PM | |
| 1 | 06-24-2015 06:06 AM | |
| 1 | 07-15-2015 12:34 PM | |
| 1 | 05-21-2015 02:27 PM | |
| 1 | 05-19-2015 11:52 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|