Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

combo and text box

 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
basic idea:
onchange="document.formName.elementName.disabled=(this.value!=-2)"

Eric
 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • 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 ]
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You forgot the form:

 
Bernard Sigmund Gustav
Ranch Hand
Posts: 170
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The form matters. I don't know what you mean by 'nearer' though
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic