/    Sign up×
Community /Pin to ProfileBookmark

Javascript being ignored

I have written a small function that changes the visibility of two input boxes, however even if the privDinRm[1] option isnt selected the second line of code still runs making the privDinRmS box visible when it should stay invisible and i cant work out why this is happening, the first box privDinRmNm still stays hidden and works fine. I have tried it in ie and firefox but both have the same problem. any ideas would be much appreciated.
thanks in advance
code below::

function privdinrm(){
if (document.register2.privDinRm[1].selected)
document.register2.privDinRmNm.style.visibility=’visible’
document.register2.privDinRmS.style.visibility=’visible’
}

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@LogicianJun 22.2006 — I have written a small function that changes the visibility of two input boxes, however even if the privDinRm[1] option isnt selected the second line of code still runs making the privDinRmS box visible when it should stay invisible and i cant work out why this is happening, the first box privDinRmNm still stays hidden and works fine. I have tried it in ie and firefox but both have the same problem. any ideas would be much appreciated.

thanks in advance

code below::

function privdinrm(){

if (document.register2.privDinRm[1].selected)

document.register2.privDinRmNm.style.visibility='visible'

document.register2.privDinRmS.style.visibility='visible'

}[/QUOTE]

[URL=http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Statements:if...else]RT*M[/URL]
Copy linkTweet thisAlerts:
@omnipitenceauthorJun 22.2006 — why did you just copy my message? thats not useful
Copy linkTweet thisAlerts:
@KorJun 22.2006 — if()

[B]{

}

[/B]
else

[B]{

}[/B]
Copy linkTweet thisAlerts:
@netbuddyJun 22.2006 — function privdinrm(){

if (document.register2.privDinRm[1].selected)

document.register2.privDinRmNm.style.visibility='visible'

document.register2.privDinRmS.style.visibility='visible'

}

the if condition you specify has no braces (curly brackets to the leyman)

you need to wrap your if condition in a set of these so that the condition when met will cause both items to operate or not...
[CODE]function privdinrm(){
if (document.register2.privDinRm[1].selected)
{
document.register2.privDinRmNm.style.visibility='visible'
document.register2.privDinRmS.style.visibility='visible'
}
}[/CODE]

when the 'selected' condition is met, BOTH items will be set to 'visible'
Copy linkTweet thisAlerts:
@LogicianJun 22.2006 — why did you just copy my message? thats not useful[/QUOTE]I didn't - I gave you a link to one of any number of resources explaining the rudiments of the language, to which you plainly failed to refer before asking.
Copy linkTweet thisAlerts:
@netbuddyJun 22.2006 — sometimes you need a large 20ft neon sign pointing at it...
×

Success!

Help @omnipitence spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...