Disable button

This is a discussion on "Disable button" within the JavaScript Forum section. This forum, and the thread "Disable button are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices




Closed Thread
 
LinkBack Thread Tools
  #1  
Old Sep 17th, 2003, 09:35
Junior Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
Yeah dito.
And now I see Mr. KuleGamr profusely apologising in the Free For All forum, so I must have missed out on some serious fun.

I hope you guys haven't permanently deleted that thread...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!

  #2  
Old Sep 17th, 2003, 09:58
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,183
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
I believe it got deleted... I am looking into the matter and will keep you informed.

Rob
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #3  
Old Sep 17th, 2003, 12:42
Junior Member
Join Date: Sep 2003
Location: Dubai, United Arab Emirates
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Part of the fun of forums is having barneys with people you don't know, or reading other people having them.

I do hope it wasn't deleted permanently.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #4  
Old Sep 17th, 2003, 12:50
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,183
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
It appears it was permenently deleted by a moderator who shall remain nameless.

He has been ticked off, and I assure all, it wont happen again.

Sorry guys.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #5  
Old Sep 17th, 2003, 12:57
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Boo!

u2o
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #6  
Old Sep 17th, 2003, 13:03
Junior Member
Join Date: Sep 2003
Location: Vatican City
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by Rob

It appears it was permenently deleted by a moderator who shall remain nameless.

He has been ticked off, and I assure all, it wont happen again.

Sorry guys.

<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
Name him please! Can we now have a thread to kick his arse instead?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #7  
Old Sep 17th, 2003, 13:24
Junior Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
<blockquote id="quote"><font size="1" face="geneva, verdana, arial" id="quote">quote:<hr height="1" noshade id="quote">Originally posted by GillBates

Part of the fun of forums is having barneys with people you don't know, or reading other people having them.

I do hope it wasn't deleted permanently.
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">

Next thing you know they'll be wanted us to talk about web development. Sheesh.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #8  
Old Aug 26th, 2004, 02:22
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,613
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Disable button

I want to make button that can be hide or shown depending the value of the textbox inside my form!

If the text box contain no value, then display the button else, hide it!

anyone can help me
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #9  
Old Aug 26th, 2004, 03:02
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,613
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
this javascript will be put inside the updata page, where the user can update their information.
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #10  
Old Aug 26th, 2004, 06:42
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
add an ID to your text box and your button, then add this code:

Code: Select all
textboxvalue = document.getElementByID('text1').value;

if (textboxvalue == "") {
document.getElementById('button1').disabled = false;
}
else {
document.getElementById('button1').disabled = true;
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #11  
Old Aug 26th, 2004, 09:57
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,183
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
I should point out that the above code, although correct, would need to be contained inside a function. The function would need to be called by the textbox's onchange event.

Post back here if you have problems achieving this modification.
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #12  
Old Aug 27th, 2004, 04:19
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,613
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
well thanx benbacardi, and thanx rob for reminding me
let me try it out first!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #13  
Old Aug 28th, 2004, 03:17
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,613
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
hai rob and benbacardi...
i have a hard day trying to run the code. actually i dont know how to use it.
can you show me how to do it,please
can you show me the <HEAD> script as well

this is the code page that will contain two textbox (subject,section)
and two button(update record,delete)--<u>delete will empty the textbox value =''</u>
this is my update page(dbUpdate.asp)
disable the two button if both the textbox contain value inside it!

Code: Select all
<tr>
	    <td width="31%" height="28" align="center"> 
               <p align="right"><font face="Verdana" size="2">
	       Subject :</font> 
           </td>
        
  	   <td width="69%" height="28" align="center"> 
               <div align="left"><font face="Verdana" size="2">
               <input id="subject" name="subject" value="<%=(Recordset1.Fields.Item("subject").Value)%>" size="32" style="float: left">               </font></div>
           </td>
        </tr>
        
	<tr> 
            <td width="39%" height="28" align="center"> 
               <p align="right"><font face="Verdana" size="2">
	       Section :</font> 
            </td>
            <td width="61%" height="28" align="center"> 
               <div align="left"><font face="Verdana" size="2"> 
               <input id="section" name="section" value="<%=(Recordset1.Fields.Item("section").Value)%>" size="32" style="float: left">
               </font></div>
            </td>
        </tr>
        
        <tr> 
            <td width="100%" height="28" align="center" colspan="2"> 
               <font face="Verdana, Arial, Helvetica, sans-serif" size="2">*</font>
            </td>
        </tr>
        
        <tr> 
            <td width="100%" height="28" align="center" colspan="2"> 
               <font face="Verdana, Arial, Helvetica, sans-serif" size="2"> 
               <input type="submit" value="Update Record" name="submit">
               
               <input type="button" value="Delete Record" name="delete" a href="#" onClick="document.getElementById('subject').value =''; document.getElementById('section').value = '';">
               </font>
               
            </td>
        </tr>
When the textbox "Subject" and "Section" are empty, contain no value, then display the "Update Record" button!
Else if the textbox "Subject" and "Section" contain a value/ data, then disable the "Update Record" and "Delete" button
and display a "BACK" button to go back to previous page!
<span style="color:maroon">can you show me step by step</span id="maroon">
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #14  
Old Aug 28th, 2004, 10:07
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts
ok.... first you need to add an id to the two buttons:

Code: Select all
<input id="update" type="submit" value="Update Record" name="submit">
<input id="delete" type="button" value="Delete Record" name="delete" a href="#" onClick="document.getElementById('subject').value =''; document.getElementById('section').value = '';">
next, you need to write the function that disables the button. This will need to be in the head of the page, in <script></script> tags:

Code: Select all
<script language="javascript" type="text/javascript">
<!--

function check() {

if ((document.getElementById("subject").value = "") && (document.getElementById("section").value = "")) {
document.getElementById("update").disabled = false;
document.getElementById("delete").disabled = true;
}
else {
document.getElementById("update").disabled = true;
document.getElementById("delete").disabled = false;
}
}

//-->
</script>
next, you need to add an onchange event to the two text boxes, that calls the function:

Code: Select all
<input onchange="check()" id="subject" name="subject" value="<%=(Recordset1.Fields.Item("subject").Value)%>" size="32" style="float: left">
<input onchange="check()" id="section" name="section" value="<%=(Recordset1.Fields.Item("section").Value)%>" size="32" style="float: left">
of course, if you want it to be checked when the page loads, you also need to add the function call in the onload event of the body:

Code: Select all
<body onload="check()">
hope this helps....

i wasn't too sure about what you meant by the back button....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #15  
Old Aug 29th, 2004, 08:51
Rob's Avatar
Rob Rob is offline
Webforumz Founder
Join Date: Jul 2003
Location: Southern UK
Age: 34
Posts: 3,183
Blog Entries: 7
Thanks: 28
Thanked 22 Times in 19 Posts
Monie.... please can you use forum code when posting script. You need to surround any pasted code with these tags:
[*code] script here [*/code] (remove asterisks)
__________________
Click the 'Thanks!' button if this post has helped you

Rob - Webforumz Founder
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #16  
Old Aug 30th, 2004, 03:32
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,613
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Code: Select all
testing....
ok rob,
thanx for telling me that:)
and thanx a lot for benbacardi! Your code really helps me alot!
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #17  
Old Aug 30th, 2004, 03:35
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,613
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
hey guys....
i am wondering, if I can disable a button, can i disable a text as well?
what changes i must do in the code if i want to disable a text?
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #18  
Old Aug 30th, 2004, 06:21
Most Reputable Member
Join Date: Jul 2003
Posts: 1,856
Thanks: 0
Thanked 0 Times in 0 Posts
You don't need to change anything other than use the id for the text field in the disabling code.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #19  
Old Aug 31st, 2004, 06:22
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,613
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
hey benbacardi, i am having a big problem here!
could you help me please

the code that you gave me is to check if the "subject" and "section" field contain a value!

if it contain a value, disable the book button, and if it does not contain any value enable all the button.i have done that successfully...thanx to you

i have modify the code to check a field called "type",
if the field contain value equal to "FIXED" and "BOOKED", disable the book button! this field is entered by the admin!

but if the field contain the value "AVAILABLE"(set by admin), enable the book botton!
can you help me! i have been trying to modify the code but i dont know how to do
the checking part

this is the unfinished code that i have done...
Code: Select all
<script language="javascript" type="text/javascript">
<!--
function check() {

if (document.getElementById("type").value ="<%=(Recordset1.Fields.Item("type").Value)%>")
{
document.getElementById("book").disabled = true;
document.getElementById("back").disabled = false;
document.getElementById("close").disabled = false;
}
else
{
document.getElementById("book").disabled = false;
document.getElementById("back").disabled = false;
document.getElementById("close").disabled = false;
}
}
<span style="color:red">logic:
if field "type" contain "FIXED" or "BOOKED"---> disable book button
else if field "type" contain "AVAILABLE"---> enable all button
</span id="red">

please help me
Last Blog Entry: ASP Programming Tips and Technique (Oct 26th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
  #20  
Old Aug 31st, 2004, 06:38
benbacardi's Avatar
Highly Reputable Member
Join Date: Feb 2004
Location: United Kingdom
Age: 20
Posts: 611
Thanks: 0
Thanked 0 Times in 0 Posts