Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help

Status
Not open for further replies.

sam1996

Programmer
Sep 3, 2006
12
CA
Hi

I am new to CF and I am writing an a pplication with CF, and I dont know how is the compatibilty between Javascript and CF, I mean can I use cfselect in my script and other elements or should I use cfscript, my problem write now is

function getprov(){


var pairs ;
var provin ;
var idx ;
idx = document.URL.indexOf("?");

if (idx != -1){
pairs = document.URL.substring(idx+1,document.URL.length).split ("&");

alert( pairs);
idx = unescape(pairs);
var j= idx.indexOf("=");
alert ("j"+ j);
var i = pairs.length;
alert("i"+ i);
provin = pairs.substr(j,i);

alert ("provin =" + prov);
document.getElementById(province).VALUE = provin;}

document.getElementById("province").VALUE = "AL";
}first is error object does not support properity, pairs.length, second i = 1, which is not suppose to be , by the way I am trying to get URL variable and set and option in cfselect box according to it. thanks
 
Don't know what it's all about. Only know VALUE is incorrect.
[tt]
//etc etc
document.getElementById(province).[red]value[/red] = provin;
} [red]else {[/red]
document.getElementById("province").[red]value[/red] = "AL";
}
}
[/tt]
ps. Do not cross-post too lightly.
 
thanks for the help, I know, sorry about that mess in the code, the problem I am getting is object does not support properity or method, pairs.length which is a URL variable and its value and index of (=), so why is it 1 , socond why object pairs does not support properity or method which is length in this case.
 
> why object pairs does not support properity or method which is length in this case.
It should... so it is not the error line.

The error should be this line.
>provin = pairs.substr(j,i);
But you already make an entanglement, so it is hard to dismantle.

pairs is an Array.
>idx=unescape(pairs)
Though work, make an implicit join() to the pairs. Besides you use idx again which change its meaning! Why don't use other name?

If you want to extract the query variable name/value pair, I guess you confirm yourself to the case where only _one_ variable/value pair. Hence, after the alert(pairs), replace every instance of pairs by pairs[0]. Then you would get something sensible amid very restrictive on the structure of the query string.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top