/    Sign up×
Community /Pin to ProfileBookmark

Hide show function

I have a function that hides or shows a drop down box depending on whixh radio button is selected. I had toggleing between 2 radio buttons working fine but then i added a third option and i cant get the hiding and showing of the drop down boxes to show correctly. Basically once the hardware radio button is selected i want to view the hardware drop down and hide the software drop down and other drop down. once the software radio button is selected i want to view the software drop down and hide the hardware and other drop down and the same applies for when the other radio button is selcted.

Can anyone help as its just not working right.

Many thanks

my code is attached

[upl-file uuid=c0327f21-7a8f-47e7-bafb-91946f37e105 size=4kB]code1.txt[/upl-file]

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 17.2003 — toggleT(_show,_hide,_hide) has two variables _hide, which is in fact one(re-definition of variable).

Do this:

toggleT(_show,_hide1,_hide2) {

document.getElementById(_
show).style.visibility='visible';

document.getElementById(_hide1).style.visibility='hidden';

document.getElementById(_
hide2).style.visibility='hidden';

}
Copy linkTweet thisAlerts:
@rob_cartauthorSep 17.2003 — Nice one fang, sorted. The only problem is that when the page initially shows 2 of the 3 drop down boxes are there and i dont want to see any when the page initally loads.

Any ideas ?
Copy linkTweet thisAlerts:
@FangSep 17.2003 — Set visibility:hidden for id sh_sw and sh_ot

[COLOR=green]<span id="sh_sw" style="visibility:[COLOR=red]visible[/COLOR];position:relative;top:0;left:0" >[/COLOR]
Copy linkTweet thisAlerts:
@rob_cartauthorSep 17.2003 — nice one fang,

Now i need to post the selection out of the choosen drop down box. At the moment it will post all 3 selections (even though 2 are hidden) but i just want to post the selection from the one that is displayed with the radio button slection. I think i need some sort of if statement thta says when this radio button is selcted post this data (from displayed drop down) and ignore this data (data in hidden drop downs).

Sorry to nag you but i think im in over my head at the moment !!!

Any ideas would be gratefully recieved.

Thanks
Copy linkTweet thisAlerts:
@FangSep 17.2003 — I assume you can't or won't change the sendmail.cgi(or what ever script is used)

A few options - do one of the following with onsubmit():

1) in a hidden field in the page, fill with the value/text from the visible option menu.

2) delete the value/text from the selected hidden option menus
Copy linkTweet thisAlerts:
@rob_cartauthorSep 17.2003 — so i need to create a hidden field and put in what ever value is choosen from the drop down box, which is determined by the state of the radio buttons. Its all too confusing !!!

Sould this all be done in javascript ?
Copy linkTweet thisAlerts:
@FangSep 18.2003 — It would be better server side, but the same check would have to be made.

Another alternative is to have 3 forms - visible or hidden according to the state of the radio buttons.

Then only the relevent form would be sent.

Should all this be done with Javascript? The purists would say NO, form validation/processing should be done server side.

It's your website.
×

Success!

Help @rob_cart 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 5.16,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...