JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 26th, 2012, 02:50 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 762 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 28 m 2 sec
Reputation Power: 339
This.form.name not working!

Hello all
Sorry to post what may be such an obvious or schoolboy problem but I can't see why this simple code works on one website I wrote, but not another!

PHP Code:
echo "<form method='post' name='customer' id='customer'>";
        echo 
"<a href='#' onclick='alert(this.form.name);'>select all</a> <br />";
    echo 
"</form>"



When I click on the 'select all' link, nothing happens; if I change it to alert 'this.form', I get "undefined" but as you can see, I have named and ID'd my form!
I have searched google and the syntax etc all appears to be correct (and as I mentioned above, I have used this code on other websites without problem).

Does anyone have any suggestions please?!
__________________
The number for UK Emergencies is changing, the new number is 0118 999 881 999 119 7253

"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984

Reply With Quote
  #2  
Old September 26th, 2012, 08:41 AM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,932 Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 13 h 8 m 31 sec
Reputation Power: 2632
Can you post the entire HTML document please.
__________________
[PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

W3Fools - A W3Schools Intervention.

Reply With Quote
  #3  
Old September 26th, 2012, 09:08 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 762 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 28 m 2 sec
Reputation Power: 339
Quote:
Originally Posted by Winters
Can you post the entire HTML document please.


Sure ...

PHP Code:
<!DOCTYPE html>
<
html>
<
head>
</
head>
<
body>
<?
php
echo "<form method='post' name='customer' id='customer'>";
        echo 
"<a href='#' onclick='alert(this.form.name);'>select all</a> <br />";
echo 
"</form>"
?>
</body>
</html> 


I was trying to add a Select ALL / NONE / Toggle to an existing page and when it decided not to work I wrote that code to test the code without any external "interference" and discovered that it refused to work when there was nothing else going on!

I've also viewed page source and copied that into "newfile.html" (in effect dropping all PHP) and it still refuses to work!

For what it's worth, here's the "view source" from the above PHP ...

Code:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form method='post' name='customer' id='customer'><a href='#' onclick='alert(this.form.name);'>select all</a> <br /></form></body>
</html>

Reply With Quote
  #4  
Old September 26th, 2012, 10:09 AM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,932 Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 13 h 8 m 31 sec
Reputation Power: 2632
That seemed like a very eye-rolling "sure" I wanted to see the document type and charset.
An anchor is not part of a form so it cannot reference a form as a form element parent child. It can be referenced as a parent node.
Javascript Code:
Original - Javascript Code
  1. this.parentNode.name

Last edited by Winters : September 26th, 2012 at 10:16 AM. Reason: additional

Reply With Quote
  #5  
Old September 26th, 2012, 10:23 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 762 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 28 m 2 sec
Reputation Power: 339
I see, ok yes, that makes sense now!

As for the 'sure ...' haha well the code I had posted was the entire page at the time of posting, I later added the rest of the HTML to see if that would make a difference ... apparently not.
I'm on with something else now though but when I revisit the select all / none / toggle, I will use a button.

ps. With regards to nicking the line from other code, I re-checked the original source and the onclick was taken from a submit button, doh

THANK YOU for the reply and assistance, it's very much appreciated!

Reply With Quote
  #6  
Old September 26th, 2012, 10:26 AM
Winters Winters is offline
Super Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jul 2003
Posts: 3,932 Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level)Winters User rank is General 25th Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 2 Days 13 h 8 m 31 sec
Reputation Power: 2632

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > This.form.name not working!

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap