Click to See Complete Forum and Search --> : NaN confusion
caseym
08-11-2003, 04:50 PM
Hi,
I have a cookie that contains login values that I need to get at. I can get the values from the cookie and use alerts to view them however when I put them into the text and password fields I get "Nan."
Do I need to do some additional processing on these values to get them to display properly?? I'm kind of at a loss here.
Any input is greatly appreciated.
Thanks,
Casey
NaN is telling you that the variable is not a number. You must be doing some sort of processing on the variable (adding, multiplying, etc..) Can we see some code?
caseym
08-11-2003, 05:03 PM
Here's the code I'm working with
// get the cookie, find the ID field
var Cookie = document.cookie;
var start = Cookie.indexOf("ID=") + 3;
var end = sccCookie.indexOf(";", start);
var szID = sccCookie.substring(start, end);
// this alert give the proper value for szID however when
// I put it into the text field I get 'Nan'
alert("Start: " + start + " End: " + end + "szID: " + szID);
document.write("<input class='forminput' type='text'"
+ "value='" + szID + "' name='userid' size='30'>");
Thanks,
Casey
A few quotes problems going on there... Try this one:
document.write("<input class='forminput' type='text' value='" + szID + "' name='userid' size='30'>");
caseym
08-11-2003, 05:11 PM
Thanks but no luck.
It worked fine for me, when I gave szID a value:
<script type="text/javascript">
szID = 1;
document.write("<input class='forminput' type='text' value='" + szID + "' name='userid' size='30'>");
</script>
caseym
08-11-2003, 05:23 PM
When I set szID to 1 it works fine here as well. I am populating the field with an email address. How can I populate the field with the email address without getting NaN??
I can just put a javascript block below the field declaration (terminology is most likely off here) that sets the value of the field to the ID and it works properly. For future reference, is there something that I can do to be able to populate the field with a string the way I mentioned previously??