/    Sign up×
Community /Pin to ProfileBookmark

How to disable on click?

How do I disable an input field when someone clicks a checkbox? what is code for this, please?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@ahk2chanAug 23.2006 — Here is an example:
<i>
</i>...
&lt;input type="text" name="testbox"&gt;
&lt;input type="checkbox" name="testcheck" onClick="if ( this.checked ) { testbox.disabled=true; }"&gt;
...
Copy linkTweet thisAlerts:
@webcrawlerauthorAug 23.2006 — Here is an example:
<i>
</i>...
&lt;input type="text" name="testbox"&gt;
&lt;input type="checkbox" name="testcheck" onClick="if ( this.checked ) { testbox.disabled=true; }"&gt;
...
[/QUOTE]

hi,

I've already got the following code on the checkbox as such:

[CODE]<INPUT onclick="create_prev();" type="radio" value=nobuttons name=adtype>[/CODE]

If I was to add your code, how would this be done?

thanks

to be precise: how would I add the command: "if ( this.checked ) { testbox.disabled=true; }" ?
Copy linkTweet thisAlerts:
@ahk2chanAug 23.2006 — you can either add it before or after your method call. For example:
<i>
</i>&lt;INPUT onclick="create_prev(); [b]if ( adtype.value=='nobuttons' ) { testbox.disabled=true; }[/b] " type="radio" value=nobuttons name=adtype&gt;

(I have changed the condition in the "if" statement to make it matching your radio button instead of checkbox.)
Copy linkTweet thisAlerts:
@webcrawlerauthorAug 23.2006 — hmm...

I put in the code as you suggested so that it is now:

[CODE]<INPUT onclick="create_prev(); if ( adtype.value=='nobuttons' ) { email.disabled=true; } " type="radio" value=nobuttons name=adtype>[/CODE]

However, it is not showing up at all.

Here is the surrounding code:

<p>

<label>

Instant Opt-In

</label>

<INPUT onclick="create_prev()" type=radio Checked value=send name=adtype>

<span class="question">

<A onmouseover="MM_swapImage('Image119','','../images/help1.gif',1)"

onclick="window.open('popover-help.html#default', 'personalize', 'status=no,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,width=470,height=350,Top=0,Left=0');"

onmouseout=MM_swapImgRestore() href="javascript:void(0)" #personalize="">

<IMG id=Image1 height=14 alt=Help src="../images/help.gif" width=15 border=0 name=Image119></A>

</span>

</P>


<p>
<label>
Hide Buttons
</label>
<INPUT onclick="create_prev(); if ( adtype.value=='nobuttons' ) { email.disabled=true; } " type="radio" value=nobuttons name=adtype>
<span class="question">
<A onmouseover="MM_swapImage('Image118','','../images/help1.gif',1)"
onclick="window.open('popover-help.html#Nobuttons', 'personalize', 'status=no,toolbar=no,scrollbars=yes,resizable=yes,menubar=no,width=470,height=350,Top=0,Left=0');"
onmouseout=MM_swapImgRestore() href="javascript:void(0)" #personalize="">
<IMG id=Image1 height=14 alt=Help src="../images/help.gif" width=15 border=0 name=Image118></A>
</span>
</p>


<p>
<label>
Autoresponder Email
</label>
<INPUT onblur="create_prev()" onfocus="this.select();this.onfocus=null" size=19 name=email>
</p>


it's found here on the [URL=http://www.freepopupcreator.com/index3.php]free pop up creator[/URL] page
Copy linkTweet thisAlerts:
@ahk2chanAug 23.2006 — Hi, please try to use: (I have bolded the change)
<i>
</i>&lt;INPUT onclick="create_prev(); if ( [b]this.checked[/b] ) { email.disabled=true; } " type="radio" value=nobuttons name=adtype&gt;

Thanks.
Copy linkTweet thisAlerts:
@webcrawlerauthorAug 24.2006 — Thank you! ?
×

Success!

Help @webcrawler 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.28,
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,
)...