We help IT Professionals succeed at work.
Get Started

I want to display '' rather than 0 in textbox

u0867587 asked
Last Modified: 2012-05-12
When user selects an option, it displays 0. I want it to display '' instead of 0. But the user may enter in 0 if they wish. Does anyone know how this can be done?

To select an option in the fiddle, click on open grid and select one of the 3 options '3', '4' or '5'. When you selected an option it will display a textbox below which says '0'. I want it to be blank. The user can enter in 0 if they wish but the textbox must start of blank.

I believe the 0 is caused because there is no answers button (A, B, C...), selected so it displays 0. Below is code which is causing this:
             var $this = $(this);
             var context = $this.parents('.optionAndAnswer');
         $('.answertxt', context).val(context.find('.answerBtnsOn').length);

Open in new window

Jsfiddle application can be accessed here
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE