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.



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

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
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...

  #2 (permalink)  
Old Sep 17th, 2003, 09:58
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
I believe it got deleted... I am looking into the matter and will keep you informed.

Rob
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #3 (permalink)  
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.
  #4 (permalink)  
Old Sep 17th, 2003, 12:50
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to 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.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #5 (permalink)  
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
  #6 (permalink)  
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?
  #7 (permalink)  
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.
  #8 (permalink)  
Old Aug 26th, 2004, 02:22
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #9 (permalink)  
Old Aug 26th, 2004, 03:02
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #10 (permalink)  
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
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
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;
}
  #11 (permalink)  
Old Aug 26th, 2004, 09:57
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
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.
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #12 (permalink)  
Old Aug 27th, 2004, 04:19
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #13 (permalink)  
Old Aug 28th, 2004, 03:17
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #14 (permalink)  
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
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
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....
  #15 (permalink)  
Old Aug 29th, 2004, 08:51
Rob's Avatar
Rob Rob is offline
Head Admin & CEO

SuperMember
Join Date: Jul 2003
Location: at my desk
Age: 34
Posts: 2,952
Blog Entries: 7
Thanks: 7
Thanked 4 Times in 4 Posts
Send a message via MSN to Rob Send a message via Skype™ to Rob
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)
__________________
Rob - SEO Specialist
Owner & Founder of Webforumz.com

I am currently unavailable for private work
  #16 (permalink)  
Old Aug 30th, 2004, 03:32
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #17 (permalink)  
Old Aug 30th, 2004, 03:35
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #18 (permalink)  
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.
  #19 (permalink)  
Old Aug 31st, 2004, 06:22
Most Reputable Member
Join Date: Feb 2004
Location: Borneo
Age: 27
Posts: 1,608
Blog Entries: 2
Thanks: 0
Thanked 4 Times in 3 Posts
Send a message via Yahoo to Monie
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)
  #20 (permalink)  
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
Send a message via MSN to benbacardi Send a message via Skype™ to benbacardi
you need another if statement:

Code: Select all
if (document.getElementById('type').value == "FIXED" || document.getElementById('type').value = "BOOKED") {
document.getElementById('book').disabled = true;
}
else if (document.getElementById('type').value == "AVAILABLE") {
document.getElementById('book').disabeld = false;
}
Closed Thread

Tags
disable, button

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Right click disable.. tipgal JavaScript Forum 6 Feb 10th, 2008 18:46
How to retain the disable state of the button after page refreshing srinivasyadav JavaScript Forum 1 Sep 9th, 2007 14:17
How to disable a hyperlink or a textbox or a command button? jeffry PHP Forum 1 Feb 13th, 2007 11:01
When a button refuses to behave like a button in Flash autumn_whispers2me Flash & Multimedia Forum 2 May 24th, 2005 22:08
[SOLVED] Disable Button while using Tabs Anonymous User JavaScript Forum 1 Sep 14th, 2004 09:12


All times are GMT. The time now is 00:03.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43