# Syntax for checking a textbox is in inactive state

**URL:** <https://rubytalk.org/t/syntax-for-checking-a-textbox-is-in-inactive-state/55011>\
**Category:** ruby-talk\
**Created:** [21 August 2009 14:52 UTC](https://rubytalk.org/t/syntax-for-checking-a-textbox-is-in-inactive-state/55011 "2009-08-21T14:52:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Candler](https://avatars.discourse-cdn.com/v4/letter/b/5f9b8f/32.png) [@Brian\_Candler](https://rubytalk.org/u/Brian_Candler)\
**Post date:** [21 August 2009 14:52 UTC](https://rubytalk.org/t/syntax-for-checking-a-textbox-is-in-inactive-state/55011/1 "2009-08-21T14:52:55Z")

</div>

Wow, a question with so much missing information. I am guessing:

(1) "Webpage" means "a HTML page containing a FORM element"?

(2) "chk" means "when the FORM arrives at my webserver, I want to take  
action dependent on whether the checkbox is checked or not"?

(3) The server is running some web framework, I guess Rails?

In that case maybe what you want is:

&nbsp;&nbsp;def myaction  
&nbsp;&nbsp;&nbsp;&nbsp;if params[:checkboxname]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;render :text =\> "It was checked!"  
&nbsp;&nbsp;&nbsp;&nbsp;else  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;render :text =\> "It was not checked!"  
&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;end

My guesses could be entirely off-base. For example, you might want to be  
testing the checkbox state browser-side in Javascript. The moral is: if  
you want a good answer, please make the effort to post a good question.  
See  
[http://www.catb.org/~esr/faqs/smart-questions.html#intro](http://www.catb.org/~esr/faqs/smart-questions.html#intro)

If you show your existing code (both the HTML template and the  
controller action which handles it) you may get a more accurate answer.  
But if it's a Rails question, it would be better that you don't post it  
here, use a Rails mailing list instead.

Regards,

Brian.

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
