Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #9474 > unrolled thread
| Started by | Ted Byers <r.ted.byers@gmail.com> |
|---|---|
| First post | 2011-12-20 14:24 -0800 |
| Last post | 2011-12-21 00:55 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.javascript
How do I fi 'Unable to get value of the property 'options': object is null or undefined' with document.getElementById Ted Byers <r.ted.byers@gmail.com> - 2011-12-20 14:24 -0800
Re: How do I fi 'Unable to get value of the property 'options': object is null or undefined' with document.getElementById Jake Jarvis <pig_in_shoes@yahoo.com> - 2011-12-21 00:50 +0100
Re: How do I fi 'Unable to get value of the property 'options': object is null or undefined' with document.getElementById Jake Jarvis <pig_in_shoes@yahoo.com> - 2011-12-21 00:55 +0100
| From | Ted Byers <r.ted.byers@gmail.com> |
|---|---|
| Date | 2011-12-20 14:24 -0800 |
| Subject | How do I fi 'Unable to get value of the property 'options': object is null or undefined' with document.getElementById |
| Message-ID | <c6bd7089-1661-487f-a006-a3cb15c55849@h11g2000yqd.googlegroups.com> |
Here is the first bit of the part of my Pel script that produces the
problem Javascript function:
print "function validateFormData() {
var vtf = document.getElementById('vt');\n
var x = vtf.ccn.value
var msg = \"\";
var newline = \'CR\';
if (x==null || x==\"\") {
vtf.ccn.bgColor=\"lightred\";
alert(\"Credit card number must be provided\");
return false;
}
And of course the function goes on to try to validate a couple dozen
input controls on the form that has the id 'vt'
This is especially puzzling since I have other Javascript functions
that seem to work fine, vis:
print "var vtf = document.getElementById('vt');\n";
print "var btemp=vtf.bstate\n";
print "var stemp=vtf.sstate\n";
print "function countrychange(x,c) {
if (c == 1) {
for (m=btemp.options.length-1;m>0;m--)
btemp.options[m] = null
for (i=0;i<group[x].length;i++)
btemp.options[i]=new Option(group[x][i].text,group[x]
[i].value)
btemp.options[0].selected=true
} else {
for (m=stemp.options.length-1;m>0;m--)
stemp.options[m] = null
for (i=0;i<group[x].length;i++)
stemp.options[i]=new Option(group[x][i].text,group[x]
[i].value)
stemp.options[0].selected=true
}
}\n";
Two functions that start like the first can't seem to find the form
called 'vt', using document.getElementById, and thus don't do
anything.
This is especially puzzling since both worked fine when I used
document.vt, but then failed when I moved the form vt from being the
only thing in the document to be within a set of nested tables (that I
used to provide my layout (I couldn't get div tags to give me the
layout I required)).
I don't know if you need to know this, but I am producing all my pages
using CGI written in Perl (because the content is dynamic, and access
is controlled by user credentials and the usual sesion management
practices). I am just having rouble with logout ending a session and
redirecting the user to the login page. I suspect that is a problem
with the Perl I am writing, but if Javascript can help, I'd love to
hear about it.
I am also MUCH more familieer with Perl than I am with Javascript.
The browsers I am most concerned about are MS IE and Firefox, but I am
trying to use HTML5 as much as possible, so that when the time comes,
we can adapt this intrface to mobile devices. I am already seeing
differences in support of HTML5 between FireFox and MS IE. :-( But
that is hardly relevant here.
Any insights would be greatly appreciated.
Thanks
Ted
[toc] | [next] | [standalone]
| From | Jake Jarvis <pig_in_shoes@yahoo.com> |
|---|---|
| Date | 2011-12-21 00:50 +0100 |
| Subject | Re: How do I fi 'Unable to get value of the property 'options': object is null or undefined' with document.getElementById |
| Message-ID | <9lcl9aF3fdU1@mid.uni-berlin.de> |
| In reply to | #9474 |
On 20.12.2011 23:24, Ted Byers wrote:
> Here is the first bit of the part of my Pel script that produces the
> problem Javascript function:
>
It's interesting that your program got written by another program, but
not really relevant.
What ultimately matters is the output source code that gets evaluated by
the browser, and of course the html markup which that script is supposed
to act upon and ideally how they are "put together".
Consider posting a URL to the original document, or an SSCCE ("Short,
Self Contained, Correct (Compilable), Example", see http://sscce.org/),
else this might degenerate into a game of 20 questions or lots of failed
attempts at remote viewing.
<snip>
--
Jake Jarvis
[toc] | [prev] | [next] | [standalone]
| From | Jake Jarvis <pig_in_shoes@yahoo.com> |
|---|---|
| Date | 2011-12-21 00:55 +0100 |
| Subject | Re: How do I fi 'Unable to get value of the property 'options': object is null or undefined' with document.getElementById |
| Message-ID | <9lclj2F5ljU1@mid.uni-berlin.de> |
| In reply to | #9479 |
On 21.12.2011 00:50, Jake Jarvis wrote:
> On 20.12.2011 23:24, Ted Byers wrote:
>> Here is the first bit of the part of my Pel script that produces the
>> problem Javascript function:
>>
>
> It's interesting that your program got written by another program, but
> not really relevant.
>
> What ultimately matters is the output source code that gets evaluated by
> the browser, and of course the html markup which that script is supposed
> to act upon and ideally how they are "put together".
>
> Consider posting a URL to the original document, or an SSCCE ("Short,
> Self Contained, Correct (Compilable), Example", see http://sscce.org/),
> else this might degenerate into a game of 20 questions or lots of failed
> attempts at remote viewing.
>
> <snip>
>
Also see http://www.jibbering.com/faq/notes/posting/ from the beginning
or possibly from http://www.jibbering.com/faq/notes/posting/#ps1Code
--
Jake Jarvis
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web