Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 01-04-2007, 01:34 PM   #1 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Javascript: Null or not an object? [IE]

For some reason in IE, it says a form value is not an object, or is null.
In FF, it works fine, because, of course, it is filled.

Here is the code:
Code:
function getformvalues (fobj){ var str = ""; aok = true; var val; fobj = document.getElementById(fobj); //Run through a list of all objects contained within the form. for(var i = 0; i < fobj.elements.length; i++) { str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&"; } //Then return the string values. return str; }
Now, maybe that is different for IE? I'm not sure, but it should work from my understanding.

Thanks for any help.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!

Last edited by Izzmo; 01-04-2007 at 01:38 PM..
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-04-2007, 02:05 PM   #2 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Source Page: http://www.PinnacleofDestruction.net/juksing/new
Username: Me@Izzmo.com
Password: 1234
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-04-2007, 03:49 PM   #3 (permalink)
Junior Member
 
Join Date: 12-27-06
Posts: 5
iTrader: 0 / 0%
Latest Blog:
None

liquidfire is liked by many
shouldnt

Code:
for(var i = 0; i < fobj.elements.length; i++) {
be

Code:
for(i = 0; i < fobj.elements.length; i++) {
see http://www.w3schools.com/js/tryit.as...=tryjs_fornext

or am I missing something?
liquidfire is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-04-2007, 03:57 PM   #4 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,784
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Looks like it should work but I have seen IE be more finicky about javascript. The only thing I could see so far is I usually stick javascript: in front of short lines of javacript on event handlers.

For example on this line of your HTML
Code:
<input type="Submit" value="Login" onClick="change('login.php', document.getElementById('logins'), 'login');" />
I would add:

onClick="javascript:change(......

What is the change function? No code for it so I don't know how it is calling the function with the problem. My error is line 24, Character 3. In the file that has this function what is on or around line 24?

The error reads:
'elements.0.value' is null or not an object.

It acts like it is not successfully executing the getElementByID method. It doesn't have an object in fobj after trying to get the element.

Good Luck
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-04-2007, 09:35 PM   #5 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Angry More and more problems

Quote:
Originally Posted by liquidfire View Post
shouldnt

Code:
for(var i = 0; i < fobj.elements.length; i++) {
be

Code:
for(i = 0; i < fobj.elements.length; i++) {
see http://www.w3schools.com/js/tryit.as...=tryjs_fornext

or am I missing something?
It doesn't matter, either way is fine since you are declaring the object at that point.

Quote:
Originally Posted by Taltos View Post
Looks like it should work but I have seen IE be more finicky about javascript. The only thing I could see so far is I usually stick javascript: in front of short lines of javacript on event handlers.

For example on this line of your HTML
Code:
<input type="Submit" value="Login" onClick="change('login.php', document.getElementById('logins'), 'login');" />
I would add:

onClick="javascript:change(......

What is the change function? No code for it so I don't know how it is calling the function with the problem. My error is line 24, Character 3. In the file that has this function what is on or around line 24?

The error reads:
'elements.0.value' is null or not an object.

It acts like it is not successfully executing the getElementByID method. It doesn't have an object in fobj after trying to get the element.

Good Luck
Yes, that's my current dilema lol. It works fine in FireFox, but not IE, who knows??

In IE, it is not finding the form, and I don't know why. I even went as far to add name="form" id="form", because I know sometimes IE grabs the name instead of the id, and it still doesn't work.

UPDATE!
  • Okay, the error just went away, and I'm not sure why, the code never changed, (errr). It's not a caching problem because I have set my browser to not cache pages. So, I don't know why it is working now.
  • The error does not show anymore, but it is still not grabbing the data from the form after the POST, which mean the error is still there.
Taltos:
Okay, here is the change() function you were asking for, and the subsequent getformvalues() function as well.

Code:
function getformvalues (fobj){ var str = ""; aok = true; var val; //Run through a list of all objects contained within the form. for(var i = 0; i < fobj.elements.length; i++) { str += fobj.elements[i].name + "=" + escape(fobj.elements[i].value) + "&"; } //Then return the string values. return str; } function change(src, form, theObj) { showProcBox(true); obj = document.getElementById(theObj); //For some reason, the content does not change unless I do this?? obj.innerHTML = obj.innerHTML; var str = getformvalues(form); runajax('login', src+"?"+str); showProcBox(false); }
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-05-2007, 11:12 AM   #6 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,784
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Hey Izzmo...did you get this fixed already. It seems to be working. When I use your provided test id and password I get logged in. We I tried valid appearing but made up info it told me "User not found". Looks like it works now or is there some other things not working?

If you fixed it, let us know how.
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-05-2007, 11:22 AM   #7 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Yeh, I fixed it! Late.. LATE, last night lol. It was bugging the heck out of me and I could just not sleep until I got it solved.

I did a bunch of things to solve it. Like, instead of using Javascript to pull the info out of the form, I just got JS to get the input's by id and got the information that way. So, now that I did that, I pulled the form, but later I put it back in so users could simply hit 'enter' when they were finished filling out the information. I also changed my Ajax request to a POST rather than a GET, for no reason really, and that didn't fix the problem, lol, it was the other things I stated above.

Now, as for why I still have to do this:
Code:
obj = document.getElementById(theObj); //For some reason, the content does not change unless I do this?? obj.innerHTML = obj.innerHTML;
I'm not sure why. I tried to make a work around, but it just kept giving me an error, but obj.innerHTML = obj.innerHTML really doesn't do anyhthing lol.. so I don't know why it gives me an error if I take it out, weird huh?
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-05-2007, 11:28 AM   #8 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,784
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
That is weird. I haven't run across that before but the first thing I think of is a variable scope problem. Those can get pretty strange. Just a vague suspicion but it acts like that might be it. Don't know. But it is working now. That's the most important part.
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-05-2007, 11:31 AM   #9 (permalink)
v7n Mentor
 
Izzmo's Avatar
 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,338
iTrader: 0 / 0%
Latest Blog:
Starting p90x today

Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
Yes, it is working!

See, I'm not what you call a JavaScript guru lol, so I've been thumping around in this area for the last week or so learning as much as I can. The reason is, is because I just bought this book Ajax and PHP by: Lee Babin, and it's really good, shows me exactly what I need to know. The only thing is doesn't show is problem solving the JavaScript that you don't need to know to get things working lol.

JavaScript is really weird by nature, because since it is Client-Side based, many different factors can effect your script, and every type of browser can make their own exceptions to the JavaScript code, which makes it even worse!

But, somehow, some way, I'll get used to it
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Izzmo is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Object Sketch Coding Forum 1 10-29-2007 09:28 AM
If money was not an object... Heather Forum Lobby 70 04-13-2006 12:18 PM
<object> </object> area clickable softstor Coding Forum 3 06-14-2004 12:35 PM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 08:31 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.