/    Sign up×
Community /Pin to ProfileBookmark

Hidden input feild on condition

Hi all,

I will start by stating that I do not know how to achieve what I need to do.

I have a form on the page with many feilds. One of the feilds is called “country” and another is called “VAT”.

What I need to do is if a user selects “United Kingdom” from the country list the “VAt” input feild shuld appear. This is how I see it happening:

<SCRIPT language=”JavaScript”>
function VAT() {
if(document.form1.country == ‘United Kingdom’)

“DISPLAY VAT FEILD”
{
if(document.form1.country == ‘EU Country’

and

if(!is_set(company_name))

{

“DISPLAY VAT FEILD”

else

“DO NOT SHOW VAT FEILD
++++++++++++++++++++++++++++++++++

I said I did not know what or how to do this, I am more PHP but I know I should learn JavaScript.

Can anyone point me in the correct direction and help.

Many thanks

Dereck

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoOct 28.2006 — Since PHP and Javascript are very similiar you already have most of it. To fix it change this:

if(document.form1.country == 'United Kingdom')


to

if(document.form1.country.value == 'United Kingdom')

and then to display the field:

document.getElementById('vat').style.display='block';

and to hide it:

document.getElementById('vat').style.display='none';

where 'vat' is replaced with the ID of the 'vat' field.
×

Success!

Help @dcjones 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.19,
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,
)...