• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

combo and text box

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want my textbox to be activated whenever i select the "others" value in my combo box, without having to submit a form

how to do that?
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
basic idea:
onchange="document.formName.elementName.disabled=(this.value!=-2)"

Eric
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
basic idea:
onchange="document.formName.elementName.disabled=(this.value!=-2)"

Eric



i replaced formName with the form's name and elementName with the textbox's name and placed it inside my select tag.
nothing happened

also, by defaul, i set my textbox to readonly="yes"
[ March 02, 2006: Message edited by: shuini gustav ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<select name="mySelect" onchange="document.myForm.myText.disabled=(this.value!='others');document.myForm.myText.readOnly=false">

Don't know if this works will all browsers...
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Satou kurinosuke:
<select name="mySelect" onchange="document.myForm.myText.disabled=(this.value!='others');document.myForm.myText.readOnly=false">

Don't know if this works will all browsers...



i'm using IE
this is my textbox
<input type="text" name="samplesize" readonly="yes" class="textbox" size="12">

and my combo
<select name="sample" class="textbox" onChange="document.mainform.samplesize.disabled=(this.value!='Others');document.mainform.samplesize.readOnly=false" style="width:100px;">
<option>1</option>
<option>2</option>
<option>Others</option>
</select>

doesn't work
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why doesn't this work?

in the head part, i placed:
<script language="javascript">
function enableField()
{
document.myformname.mytextboxname.disabled=false;
}
</script>

and in the body:
<a href="javascript:enableField()">Click here to enable the element<a/>
<input type="text" name="mytextboxname" disabled="true">
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You forgot the form:

 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i didn't, that was just assuming i already had the form.
why isn't this working?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
don't know You mean the html I have posted doesn't work ?
It works for me.
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it was weird
it's working now. i just placed the form tags nearer my textbox.
but it's not supposed to matter,right?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The form matters. I don't know what you mean by 'nearer' though
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well if you looked at my code, you would see it is looking for a value.

(this.value!=-2)

If you would give it a value of -2 it would work.

or you could change it to

(this.text!='Others')

Eric
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic