PDA

View Full Version : Variable undefined?



fmsd91
7 Mar 2010, 11:51 PM
Hi list!
I'm having problems with a variable declared in a javascript to call it from a html.
The html finds the variable correctly as I get the value undefined.
I am calling the variable from two different locations.
So, I have the html that is an wfs output template and looks like this:

-----------------------------------------------------
Here goes the header and then the index...

<body>
<script type="text/javascript" src="http://158.109.174.52/web_noise2/js_comp/noisescript_comp.js"></script>
<table>
<tbody>
<th>COUNTRY</th>
<th>AGGLOMERATION NAME</th>
<th><script type="text/javascript">
alert(n1+n2+n3+n11+"N");
alert(fieldn);
document.write(fieldn);
</script></th>
<tr>
<td>CZ</td>
<td>Brno</td>
<!--<td>1000</td>-->
<td>
<script type="text/javascript"> HERE GOES THE SCRIPT WHERE I CALL THE VARIABLE AND I GET THE FOLLOWING ERROR WITH THE HTML being that the value is 'undefined'.
Content-type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD>
<!-- MapServer version 5.0.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->
<BODY BGCOLOR="#FFFFFF">
processItem(): Web application error. Item name not found in layer item list.
</BODY></HTML>----------------------------------------------------------

The script is like this:
<script type="text/javascript">
var try1 = '[item name='+fieldn+' format=$value precision=0 nullformat="no value" escape=none]';
document.write(try1);
alert(fieldn);
</script>



The variable is declared here(in the js referred in the beginning in the html template):
function ctaginfo() {
var cb_ct = combo_ct.getValue();
layers=map.layers;var l=[];for(c=0;c<layers.length;c++){if(layers[c].getVisibility(true)){
if(cb_ct){
k=map.layers[c].name.split("_");
n1 = k[0];
n11 = k[1];
n31 = n11.substr(4,1);
n2 = n1.substr(1,2);
n3 = n11.substr(0,4);
fieldx = n2+n31+n3;
fieldn = '<iframe>'+n2+"N"+n3+'</iframe>';
var winctaginfo=new Ext.Window({shim:false,x:700,height:300,width:350,modal:false,title:'',html:'<iframe width="100%" height="100%" id="gtinfo" src="http://158.109.55.144/cgi-bin/wms?map=c:/ms4w/maps/map/wfs_wa.map&mode=itemnquery&qstring='+cb_ct+'&qitem=CTRY&qlayer=Agglomerations"></iframe>'});
winctaginfo.show();
return winctaginfo;
}
else{........

The variable is declared global in this javascript as var fieldn; that should return some characters of the visible layer name mixtured like ARNLD65.
If I input this variable in the html as a text it obviously works but I am not able to get the values I want depending on the layer selected.
Someone have an idea of what the problem could be?
Thanks!
Regards,
Francisco Domingues

fmsd91
8 Mar 2010, 1:48 AM
Hi list!
I'm having problems with a variable declared in a javascript to call it from a html.
The html finds the variable correctly as I get the value undefined.
I am calling the variable from two different locations.
So, I have the html that is an wfs output template and looks like this:

-----------------------------------------------------
Here goes the header and then the index...

<body>
<script type="text/javascript" src="http://158.109.174.52/web_noise2/js_comp/noisescript_comp.js"></script>
<table>
<tbody>
<th>COUNTRY</th>
<th>AGGLOMERATION NAME</th>
<th><script type="text/javascript">
alert(n1+n2+n3+n11+"N");
alert(fieldn);
document.write(fieldn);
</script></th>
<tr>
<td>CZ</td>
<td>Brno</td>
<!--<td>1000</td>-->
<td>
<script type="text/javascript"> HERE GOES THE SCRIPT WHERE I CALL THE VARIABLE AND I GET THE FOLLOWING ERROR WITH THE HTML
Content-type: text/html

<HTML>
<HEAD><TITLE>MapServer Message</TITLE></HEAD>
<!-- MapServer version 5.0.0 OUTPUT=GIF OUTPUT=PNG OUTPUT=JPEG OUTPUT=WBMP OUTPUT=PDF OUTPUT=SWF OUTPUT=SVG SUPPORTS=PROJ SUPPORTS=AGG SUPPORTS=FREETYPE SUPPORTS=WMS_SERVER SUPPORTS=WMS_CLIENT SUPPORTS=WFS_SERVER SUPPORTS=WFS_CLIENT SUPPORTS=WCS_SERVER SUPPORTS=SOS_SERVER SUPPORTS=FASTCGI SUPPORTS=THREADS SUPPORTS=GEOS INPUT=JPEG INPUT=POSTGIS INPUT=OGR INPUT=GDAL INPUT=SHAPEFILE -->
<BODY BGCOLOR="#FFFFFF">
processItem(): Web application error. Item name not found in layer item list.
</BODY></HTML>----------------------------------------------------------

The script is like this:
<script type="text/javascript">
var try1 = '[item name='+fieldn+' format=$value precision=0 nullformat="no value" escape=none]';
document.write(try1);
alert(fieldn);
</script>



The variable is declared here(in the js referred in the beginning in the html template):
function ctaginfo() {
var cb_ct = combo_ct.getValue();
layers=map.layers;var l=[];for(c=0;c<layers.length;c++){if(layers[c].getVisibility(true)){
if(cb_ct){
k=map.layers[c].name.split("_");
n1 = k[0];
n11 = k[1];
n31 = n11.substr(4,1);
n2 = n1.substr(1,2);
n3 = n11.substr(0,4);
fieldx = n2+n31+n3;
fieldn = '<iframe>'+n2+"N"+n3+'</iframe>';
var winctaginfo=new Ext.Window({shim:false,x:700,height:300,width:350,modal:false,title:'',html:'<iframe width="100%" height="100%" id="gtinfo" src="http://158.109.55.144/cgi-bin/wms?map=c:/ms4w/maps/map/wfs_wa.map&mode=itemnquery&qstring='+cb_ct+'&qitem=CTRY&qlayer=Agglomerations"></iframe>'});
winctaginfo.show();
return winctaginfo;
}
else{........

The variable is declared global in this javascript as var fieldn; that should return some characters of the visible layer name mixtured like ARNLD65.
If I input this variable in the html as a text it obviously works but I am not able to get the values I want depending on the layer selected.
Someone have an idea of what the problem could be?
Thanks!
Regards,
Francisco Domingues

mitchellsimoens
8 Mar 2010, 6:18 AM
Does this have anything to do with ExtJS? And can't any new person read how to post code?

mitchellsimoens
8 Mar 2010, 6:19 AM
How many posts you want? This doesn't have anything to do with ExtJS and learn how to post with code!

fmsd91
8 Mar 2010, 10:25 AM
No need to be rude! I don't need your kind of help...
bye mitchellsimoens

mitchellsimoens
8 Mar 2010, 10:57 AM
No need to be rude! I don't need your kind of help...
bye mitchellsimoens

You think that was rude? These forums are dedicated to Ext and their products. There are other forums that are dedicated to technologies. Like Devshed has forums that are very active for different languages/technologies. Maybe you will get the help you're asking for there.

Mike Robinson
9 Mar 2010, 7:17 AM
Here's where you went very wrong...

(1) "Here is a blob of source code... now, fix it for me." Uhhh, we can't. No one can.

(2) The "blob of source code" is large, unformatted, and completely unfocused. It's so hard to read that it frankly becomes an intrusion.

(3) There isn't an answerable, specific, on-topic question.

If you have a problem with your code, plenty of folks in plenty of forums are ready and willing to help you out. But, you need to do your homework first ... to prepare your response so as to make good use of those other people's time. Sometimes, this advance preparation actually reveals the answer to you on your own.

You are asking people to help you as a courtesy to you. Therefore, first be courteous to them.