<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Syntax for Attribute Query in HTML with embedded JavaScript in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440650#M40658</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for clarifying!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I took a look at your code and there are a number of ways to remedy this problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;First of all, your code is fine in theory. The buttons should trigger a function when clicked and your map should zoom accordingly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;onClick='executeZoomToNext("${nextpt}");'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the problem is that the value sent by your onClick is not an integer, but literally "${nextpt}" as a string. Because the variable you are trying to access is a javascript variable, the HTML treats this as a simple string. You cannot directly copy/paste javascript variables into an HTML code block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, there are two ways to handle this. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Change onClick to executeZoomToPrev(); and executeZoomToNext(); respectively and within these specific functions, get the id of the current feature using javascript. This ensures minimal changes to your current code (and is what I would do).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function executeZoomToNext(){
//var currentFeature = GET CURRENT FEATURE CODE
queryTask2 = new esri.tasks.QueryTask(mapservice+"/lurec_systems/MapServer/0");
query2 = new esri.tasks.Query();
query2.returnGeometry = true;
query2.outSpatialReference = map.spatialReference;
query2.outFields = ["objectid", "id", "name", "descrip", "system", "zoomlevel", "nextpt", "url"];
query2.where = "id = "+currentFeature+"";
queryTask2.execute(query2, showResult2);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Update the value of both onClicks dynamically each time a new feature is selected (using javascript). This way is more slightly more complicated but I have seen it in practice. (Also, this way is more work overall compared to way 1).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hopefully this makes some sense. I can try to explain in a different way if this isn't enough information to lead you in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 19:43:31 GMT</pubDate>
    <dc:creator>JonathanUihlein</dc:creator>
    <dc:date>2021-12-11T19:43:31Z</dc:date>
    <item>
      <title>Syntax for Attribute Query in HTML with embedded JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440647#M40655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to call attribute variables of the current feature in my HTML.&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://www.luc.edu/sustainability/campus/map/"&gt;This worked&lt;/A&gt;&lt;SPAN&gt; as the contents of an infoWindow in the JS file: &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;...."&amp;lt;button class='button' id='infoWindowNEXT' onClick='executeZoomToNext&lt;STRONG&gt;(\"${nextpt}\")&lt;/STRONG&gt;;' &amp;gt;NEXT &amp;lt;/button&amp;gt;"+....&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But now I need to redesign and have the contents of the infoWindow display in a side panel.&amp;nbsp; In the HTML, I can't get the attribute to come through due to syntax:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;....&amp;lt;button class='button' id='infoWindowNEXT' onClick='executeZoomToNext&lt;STRONG&gt;("${nextpt}")&lt;/STRONG&gt;;' &amp;gt;NEXT &amp;lt;/button&amp;gt;....&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What am I missing?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 03 Jun 2013 18:37:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440647#M40655</guid>
      <dc:creator>DavidTreering</dc:creator>
      <dc:date>2013-06-03T18:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax for Attribute Query in HTML with embedded JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440648#M40656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I should be able to help but I need a bit more information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I understand correctly, you want to move your button code from inside the JS file to somewhere in the &amp;lt;body&amp;gt; tag of your HTML document?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Second question, what does the "nextpt" variable generally represent in your code? (name strings, integers or a point object for example; be as specific as you can).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have any other questions, I can try to help with those as well.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Jun 2013 20:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440648#M40656</guid>
      <dc:creator>JonathanUihlein</dc:creator>
      <dc:date>2013-06-07T20:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax for Attribute Query in HTML with embedded JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440649#M40657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If I understand correctly, you want to move your button code from inside the JS file to somewhere in the &amp;lt;body&amp;gt; tag of your HTML document?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;That's correct.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Second question, what does the "nextpt" variable generally represent in your code?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;In my Feature Service, nextpt is &lt;/SPAN&gt;&lt;STRONG&gt;an integer&lt;/STRONG&gt;&lt;SPAN&gt; that simply enables me to cycle through a tour of features. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For example, feature#1 has id=1 and nextpt=2, feature#2 has id=2 and nextpt=3, etc.&amp;nbsp; I have a function to advacne and zoom to the next or previous feature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In the HTML file, this is on lines 45 and 47.&amp;nbsp; In the JS file these functions are on lines 333 and 343.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope that clarifies.&amp;nbsp; Thanks for your time and effort!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jun 2013 17:25:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440649#M40657</guid>
      <dc:creator>DavidTreering</dc:creator>
      <dc:date>2013-06-11T17:25:16Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax for Attribute Query in HTML with embedded JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440650#M40658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for clarifying!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I took a look at your code and there are a number of ways to remedy this problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;First of all, your code is fine in theory. The buttons should trigger a function when clicked and your map should zoom accordingly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;onClick='executeZoomToNext("${nextpt}");'&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, the problem is that the value sent by your onClick is not an integer, but literally "${nextpt}" as a string. Because the variable you are trying to access is a javascript variable, the HTML treats this as a simple string. You cannot directly copy/paste javascript variables into an HTML code block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now, there are two ways to handle this. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) Change onClick to executeZoomToPrev(); and executeZoomToNext(); respectively and within these specific functions, get the id of the current feature using javascript. This ensures minimal changes to your current code (and is what I would do).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
function executeZoomToNext(){
//var currentFeature = GET CURRENT FEATURE CODE
queryTask2 = new esri.tasks.QueryTask(mapservice+"/lurec_systems/MapServer/0");
query2 = new esri.tasks.Query();
query2.returnGeometry = true;
query2.outSpatialReference = map.spatialReference;
query2.outFields = ["objectid", "id", "name", "descrip", "system", "zoomlevel", "nextpt", "url"];
query2.where = "id = "+currentFeature+"";
queryTask2.execute(query2, showResult2);
}&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Update the value of both onClicks dynamically each time a new feature is selected (using javascript). This way is more slightly more complicated but I have seen it in practice. (Also, this way is more work overall compared to way 1).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hopefully this makes some sense. I can try to explain in a different way if this isn't enough information to lead you in the right direction.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good luck!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:43:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440650#M40658</guid>
      <dc:creator>JonathanUihlein</dc:creator>
      <dc:date>2021-12-11T19:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax for Attribute Query in HTML with embedded JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440651#M40659</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you! I think the first option will work better for me.&amp;nbsp; However, I have found that "currentFeature" is null despite a feature being selected.&amp;nbsp; I could use a hint on how to assign a value to that var currentFeature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I'm still confused as to why this is necessary, since I can use JS variables in the HTML in other places sucessfully, like line 54 that uses the url variable to get a photo.&amp;nbsp; Isn't there some way to "escape" the HTML, or is it because this is within a function?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jun 2013 18:20:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440651#M40659</guid>
      <dc:creator>DavidTreering</dc:creator>
      <dc:date>2013-06-11T18:20:16Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax for Attribute Query in HTML with embedded JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440652#M40660</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;1) I will look into assigning a value to currentFeature after lunch. I just need to examine your code again.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2) To be honest, I am not quite sure why it works on line 54 (and I don't believe it should).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is the code my firebug extension is seeing after the page renders.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;a class="highslide" style="float:left" onclick="return hs.expand(this);" width="420" url"}"="" href="http://147.126.65.155/Images/campus/${"&amp;gt;
&amp;lt;img id="sysPic" width="220px" url"}"="" src="http://147.126.65.155/Images/campus/mbeane_walk.jpg"&amp;gt;
&amp;lt;span class="highslide-caption"&amp;gt;Enlarge image&amp;lt;/span&amp;gt;
&amp;lt;/a&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I see that ${"url"} is replaced by mbeane_walk.jpg in the img tag but not the link tag.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have not seen that syntax used directly in an HTML code block before (unless wrapped in PHP etc). Also, it doesn't seem to work on all browsers,.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am assuming it has to do with jQuery or your web-server configuration (you are also using both jquery 1.6.4 and 1.9.1).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hopefully someone else can join this discussion and provide insight on this particular mater. It is beyond my understanding and I too would like to know the answer!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:43:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440652#M40660</guid>
      <dc:creator>JonathanUihlein</dc:creator>
      <dc:date>2021-12-11T19:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax for Attribute Query in HTML with embedded JavaScript</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440653#M40661</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;My colleague and I found a way to do this by adding two functions to the JS to store and then get the currentFeature.&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;function updateCurrentFeature(currentFeature){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; currFeature = currentFeature;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp; function getCurrentFeature(){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return currFeature;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Then since we need the currentFeature's id, within the executed queryTask we call &lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;updateCurrentFeature(addedGraphic.attributes.id)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then in the HTML, instead of trying to call the JS variable, which was being read as a string, we can pass getCurrentFeature() as the parameter to the executeZoomToPrev(currentFeature).&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;lt;button class='button' id='infoWindowPREV' onClick='executeZoomToPrev(getCurrentFeature());'&amp;gt;&amp;lt; PREV &amp;lt;/button&amp;gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks to Jon and Paul S.!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 19:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/syntax-for-attribute-query-in-html-with-embedded/m-p/440653#M40661</guid>
      <dc:creator>DavidTreering</dc:creator>
      <dc:date>2021-12-11T19:43:36Z</dc:date>
    </item>
  </channel>
</rss>

