Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Non-Editable Form Input Text

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
I saw the answer to this somewhere but now that I want it, I can't find it again!&nbsp;&nbsp;I need a form input text box with a preset value but that can not be edited.&nbsp;&nbsp;I believe it is done with onBlur but am not sure exactly how, nor do I know if any other coding is required.&nbsp;&nbsp;This form does not currently use any other JavaScript and is pure HTML.&nbsp;&nbsp;Any help would be appreciated.&nbsp;&nbsp;Thanks!<br><br>Don
 
you are correct (sort of)<br><br>there are a few things you can do:<br>1) insert this:<br>onFocus=this.blur();<br><br>**-but there is a problem with that one. it dosn't always work.<br>add a name='subButton' tag to the submit button, and then add this to all un-editable text boxes:<br><br>2) onFocus=document.theForm.subButton.focus();<br><br>3) you could have the value just typed in html, and have a hidden field with that as the value. (not sure if that makes sense)<br><br> <p>theEclipse<br><a href=mailto:eclipse_web@hotmail.com>eclipse_web@hotmail.com</a><br><a href=robacarp.webjump.com>robacarp.webjump.com</a><br>**-Trying to build a documentation of a Javascript DOM, crossbrowser, of course. E-mail me if you know of any little known events and/or methods, etc.
 
Thanks!&nbsp;&nbsp;I'll try it when I get home. This is for an order form where quantites can be changed.&nbsp;&nbsp;But for a couple items, only one per customer is allowed (it says so on the item description, but it gets ignored sometimes), or I may have only one item available.&nbsp;&nbsp;Right now, I am using a little image that looks like the input text box along with a hidden form input tag (as you suggested), but the images look different with different display set ups.&nbsp;&nbsp;I really don't want to NOT have the quantity field show up but only for asthetic reasons.&nbsp;&nbsp;If they're all real text boxes with some being uneditable, it will match perfectly.&nbsp;&nbsp;Thanks again!<br><br>Don
 
will this work for you?<br>&lt;input value='1' type=text name='textbox' onchange='document.forms[0].textbox.value=&quot;1&quot;'&gt; <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
When you can't find info, best place to start is the FAQs area :eek:) I wrote a FAQ offering theEclipse's first suggestion. Although I'm curious as to when it doesn't work... other than when the user turns JavaScript off, which makes any JavaScript solution useless (NOTE: if this is really important, there's no really great way of doing this in JavaScript if it's mission-critical). is that a browser error? <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
Thanks, but the one I was thinking of (the one I couldn't find again) does not appear to be either of these.&nbsp;&nbsp;With it, the cursor wouldn't stay in the text box long enough to do anything and if it could be changed, it would change back right away.&nbsp;&nbsp;These appear to allow the text to be edited.<br><br>Don
 
You can also use the onkeypress event to filter input. <p>nick bulka<br><a href=mailto: > </a><br><a href= > </a><br>
 
This simple little tag: onFocus=this.blur(); seems to work well enough.&nbsp;&nbsp;This is not mission critical or rocket science so it's just fine.&nbsp;&nbsp;Besides, I couldn't get the others to work at all, not being a programmer.<br><br>Thanks everyone!<br>Don
 
You can do it really simple:<br><br>&lt;input name=&quot;sum&quot; readonly value=&quot;#sum#&quot; class=&quot;drop&quot; size=4&gt;<br><br>Take note of the readonly inside of the input line.&nbsp;&nbsp;This makes it to where they cannot change the value, while still being able to dynamically assign a value.
 
Thanks, celley.&nbsp;&nbsp;Isn't readonly an Internet Explorer only thing (or was it Netscape only)?&nbsp;&nbsp;I read somewhere just this morning that it works on one but not the other.<br><br>Don
 
DonP.. It only works in IE.... sorry about that.&nbsp;&nbsp;Just another reason Netscape is a pain in my ass.&nbsp;&nbsp;Wish that there could be standards!&nbsp;&nbsp;drop me a line at <A HREF="mailto:chade78@aol.com">chade78@aol.com</A> when you find a good, simple solution.&nbsp;&nbsp;:)
 
celly, as I said above, in lieu of something more sophisticated, onFocus=this.blur();&nbsp;&nbsp;will work fine for my needs.&nbsp;&nbsp;(I thought it was IE that did not follow the standards with their special &quot;short cut&quot; code that no one else uses.)<br><br>Don
 
I looked at the entry that theEclipse submitted and the onFocus=this.blur(); statement works well.<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top