Solved

set  the tab index to the other field which is disabled by JavaScript code

Posted on 2007-11-26
10
240 Views
Last Modified: 2013-11-19
Hello EVERYONE, I set the tab index and it works whne the other field is enabled but it does NOT work when it's disabled, it skips right past it to the next enabled field... Is there any way to overcome this problem?

Thank you,
Angie H.      


<TD class="responseinside">
               <input type="text" value="<%=iProjectedPercentage5%>" tabindex=23 class="percentage" maxlength = "3" name="ProjectedPercentage5" id="ProjectedPercentage5"  onBlur="this.value=formatCurrency(this.value); projPercentage5(); specifyProjectedPercentageOther();" />&nbsp;<strong>%</strong>
               
      </td>
        <TD class="responseinside"> Other: &nbsp;<input tabindex=24 style="width:150px; font-family: Verdana; font-size: 8pt" type="text" value="<%=sProjectedPercentageOther%>"  name="ProjectedPercentageOther" id="ProjectedPercentageOther" /></TD>
            

<script>

window.onload = main;

function main(){
specifyProjectedPercentageOther();
}
function specifyProjectedPercentageOther()
{
      if(document.OPICForm.ProjectedPercentage5.value > 0){
            document.OPICForm.ProjectedPercentageOther.disabled = false;
            document.OPICForm.ProjectedPercentageOther.style.backgroundColor="#FFFFFF";
      } else {
            document.OPICForm.ProjectedPercentageOther.disabled = true;
            document.OPICForm.ProjectedPercentageOther.value = "";
            document.OPICForm.ProjectedPercentageOther.style.backgroundColor="#CCCCCC";      
      }
}
</script>
0
Comment
Question by:Gemini532
  • 6
  • 4
10 Comments
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
Is hiding it an option?
style="display:none"

when you are disabling an element by design it ignores the field completely, since it is disabled.
0
 

Author Comment

by:Gemini532
Comment Utility
how would I hide it?
can you help me with the code?
0
 

Author Comment

by:Gemini532
Comment Utility
can I just changed disabled to readonly?
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
document.OPICForm.ProjectedPercentageOther.readonly=true;
this is for readonly, you can try and see if it works.

document.OPICForm.ProjectedPercentageOther.style.display = 'none';

This is to hide it.
0
 

Author Comment

by:Gemini532
Comment Utility
Hello nizsmo:

I followed your sugestion and wrote this code:

document.OPICForm.ProjectedPercentageOther.readonly=true;

The taborder works, but the OTHER button is not readonly, meaning I can enter data in it even whne it is in its read only state... This is incorrect... Does read only work differently than disabled?

Angie
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 21

Accepted Solution

by:
nizsmo earned 500 total points
Comment Utility
No, read only should not let you type anything in:
http://www.htmlcodetutorial.com/forms/_INPUT_DISABLED.html

but I may have misspelt (or mis-cased) the readOnly, try this:
document.OPICForm.ProjectedPercentageOther.readOnly=true;
0
 

Author Comment

by:Gemini532
Comment Utility
Hi nizsmo,
I agree that there is something wrong in the JavaScript code, but he link  you sent me is for HTML
and the code you send me does not work:

document.OPICForm.ProjectedPercentageOther.readOnly=true;

There must be another way to code using readonly

Angie
0
 

Author Comment

by:Gemini532
Comment Utility
I reserached and it turns out you're right, readOnly is case sensitive and NOW I can write the the columns and before I coudl NOT but the tabbing problem still remains...and that was the problem in the first place, I could have kept the code disabled if it wasn't for the need of the application to automtically tab from the checkbox OTHER to the TextBOX next to it...

like this
___              _______________________________________
|___|  Other: |______________________________________|

So when they tab using the tab key, it shoudl go from the checkbox to the textbox which is NOW enabled because when they tab the checkbox it automatically makes the textbox enabled though the code above: document.OPICForm.ProjectedPercentageOther.readOnly=true;

HOWEVER, the problem is that instead of doing it that way, the tab moves to the next checkbox

I myself have entered the tabindex as you can see in the code below, but still it skips the textbox, can you help me find out how to fix this?

 <input type="text"  tabindex=23 class="percentage" name="ProjectedPercentage5" id="ProjectedPercentage5"  onBlur="this.value=formatCurrency(this.value); projPercentage5(); specifyProjectedPercentageOther();" />&nbsp;<strong>%</strong>
               
 </td><TD class="responseinside"> Other: &nbsp;<input tabindex=24   name="ProjectedPercentageOther" id="ProjectedPercentageOther" />

0
 

Author Comment

by:Gemini532
Comment Utility
Youre right I'm adding a new question on top of the one you already answered, that's not the righ way of doign things
Thank U for you help
readOnly worked!
0
 
LVL 21

Expert Comment

by:nizsmo
Comment Utility
Glad to help Germini532, please post another question (if you have not already) should you need assistance :)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now