Reply
Changing visibility
Old 03-24-2008, 06:51 PM Changing visibility
KkillgasmM's Avatar
Ultra Talker

Posts: 334
Name: El Phantasmo
Location: England, north west
Im trying to create a simple script that will make a <p> tag appear, but in the Firefox console I get the error

Quote:
document.form1.visible has no properties
here is the code im using:

CSS:
Code:
.visible {
visibility:hidden;}
HTML:
Code:
<p class="visible" id="visible">
        <label for="other" class="labelDef">Other</label>
        <input type="text" name="other" id="other" />
        <label for="button"></label>
        <br class="clear" />
      </p>
javascript:
Code:
function appear()
    {
        document.form1.visible.style.visibility="visible";
    }
Any ideas what Im doing wrong? I did originally set it so that the html name could be passed as an argument, as I wanted to be able to re use the script for other elements. But the script was causing me so much hassle its wound its way down to what's above!
__________________
http://www.inspindesign.co.uk
KkillgasmM is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-24-2008, 07:16 PM Re: Changing visibility
vangogh's Avatar
Post Impressionist

Posts: 8,441
Name: Steven Bradley
Location: Boulder, Colorado
First you don't need both the class and the id. In general it's one or the other. In this case I'd suggest using the id.

Try this for the funtion

HTML Code:
function appear(){
  var vis = document.getElementByID("visible");
  vis.style.visibility = "visible"
}
I don't see where in your code you're calling the function, but I'll assume you're doing that somewhere else not shown here. If not you do need to call the function at some point.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-24-2008, 07:32 PM Re: Changing visibility
KkillgasmM's Avatar
Ultra Talker

Posts: 334
Name: El Phantasmo
Location: England, north west
Thanks its working now! I was sure I had something similiar to that originially aswell!
__________________
http://www.inspindesign.co.uk
KkillgasmM is offline
Reply With Quote
View Public Profile
 
Old 03-24-2008, 07:39 PM Re: Changing visibility
KkillgasmM's Avatar
Ultra Talker

Posts: 334
Name: El Phantasmo
Location: England, north west
Hmmm Ive now tried altering the code to this:

HTML:
Code:
onClick="appear(visible)"
JS:
Code:
function appear(element)
    {
        vis = document.getElementById(element);
        vis.style.visibility = "visible";
    }
But now it wont work??
__________________
http://www.inspindesign.co.uk
KkillgasmM is offline
Reply With Quote
View Public Profile
 
Old 03-24-2008, 08:36 PM Re: Changing visibility
vangogh's Avatar
Post Impressionist

Posts: 8,441
Name: Steven Bradley
Location: Boulder, Colorado
I think you might need to wrap quotes around 'visible' when you pass it to the function in the onClick. Not 100% sure, but try

onclick="appear('visible')"
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Old 03-25-2008, 04:12 AM Re: Changing visibility
chrishirst's Avatar
Super Moderator

Posts: 11,866
Location: Blackpool. UK
that's correct, without quotes "visible" would be taken as a variable name and the value of that will be passed to the function.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-25-2008, 09:50 AM Re: Changing visibility
KkillgasmM's Avatar
Ultra Talker

Posts: 334
Name: El Phantasmo
Location: England, north west
Thanks, I used apostrophe's and it worked. Whats really annoying me is that I tried that last night and it still wouldnt work! I tried deleting my browser history to make sure that the page would refresh properly and it still made no difference!

I know it sounds like Im making it up, but Im not lol.
__________________
http://www.inspindesign.co.uk
KkillgasmM is offline
Reply With Quote
View Public Profile
 
Old 03-25-2008, 07:05 PM Re: Changing visibility
vangogh's Avatar
Post Impressionist

Posts: 8,441
Name: Steven Bradley
Location: Boulder, Colorado
I don't think you're making it up. Odd things like that have happened to me too. You'd swear you tried something one way and it didn't work and later it does work.

I think it's usually us thinking we tried something when we really missed one part of it. Either that or it's gremlins.
__________________
l Search Engine Friendly Web Design | Van SEO Design
l Tips On Marketing, SEO, Design, and Development | TheVanBlog
l Custom WordPress Themes
vangogh is offline
Reply With Quote
View Public Profile Visit vangogh's homepage!
 
Reply     « Reply to Changing visibility
 

Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.16207 seconds with 13 queries