|
-
Aug 25th, 2004, 10:14 PM
#1
Thread Starter
Member
Disable a BUTTON!
I have one page that will display all the data inside my database. at each data there will be an update link that can update the selected data!
I want to make button that can be hide or shown depending the value of the textbox inside my update form!
If the text box (txtBox1) contain no value,
then display the button else, hide it!
anyone can help me
-
Aug 26th, 2004, 02:23 AM
#2
Fanatic Member
use this function on the page_load event.
VB Code:
function set_state(){
if txtbox1 == ""{
button1.disabled = true
}else{
button1.disabled = false
}
}
-
Aug 26th, 2004, 02:24 AM
#3
Fanatic Member
if theres more than 1 button you'll need to put this in a loop as well
-
Aug 26th, 2004, 11:18 PM
#4
Thread Starter
Member
yes, i have 2 textbox, so how does the code look like if i want to add the AND function in the if statement?
the logic is like this;
if textbox1 and textbox2 is empty, disable button
else display button!
where should i put the code that you gave me?
---------------------------------------------------
function set_state(){
if txtbox1 == ""{
button1.disabled = true
}else{
button1.disabled = false
}
}
----------------------------------------------
-
Aug 27th, 2004, 10:49 PM
#5
Thread Starter
Member
disable button if textbox contain value
this is the code page that will contain two textbox (subject,section)
and two button(update record,delete)--delete will empty the textbox value =''
this is my update page(dbUpdate.asp)
disable the two button if both the textbox contain value inside it!
--------------------------------------------------------------------
<tr>
<td width="31%" height="28" align="center">
<p align="right"><b><font face="Verdana" size="2">
Subject :</font></b>
</td>
<td width="69%" height="28" align="center">
<div align="left"><b><font face="Verdana" size="2">
<input id="subject" name="subject" value="<%=(Recordset1.Fields.Item("subject").Value)%>" size="32" style="float: left"> </font></b></div>
</td>
</tr>
<tr>
<td width="39%" height="28" align="center">
<p align="right"><b><font face="Verdana" size="2">
Section :</font></b>
</td>
<td width="61%" height="28" align="center">
<div align="left"><b><font face="Verdana" size="2">
<input id="section" name="section" value="<%=(Recordset1.Fields.Item("section").Value)%>" size="32" style="float: left">
</font></b></div>
</td>
</tr>
<tr>
<td width="100%" height="28" align="center" colspan="2">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2"> </font></b>
</td>
</tr>
<tr>
<td width="100%" height="28" align="center" colspan="2">
<b><font face="Verdana, Arial, Helvetica, sans-serif" size="2">
<input type="submit" value="Update Record" name="submit">
<!--JAVASCRIPT TEXTBOX CHANGER-->
<input type="button" value="Delete Record" name="delete" a href="#" onClick="document.getElementById('subject').value =''; document.getElementById('section').value = '';">
</font></b>
<!--JAVASCRIPT TEXTBOX CHANGER END-->
</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!
can you show me step by step
if posible, i want to know the <HEAD> script as well, please
-
Aug 30th, 2004, 06:41 AM
#6
Fanatic Member
Originally posted by monie
yes, i have 2 textbox, so how does the code look like if i want to add the AND function in the if statement?
the logic is like this;
if textbox1 and textbox2 is empty, disable button
else display button!
where should i put the code that you gave me?
---------------------------------------------------
function set_state(){
if txtbox1 == ""{
button1.disabled = true
}else{
button1.disabled = false
}
}
----------------------------------------------
Code:
if (textone == "" && texttwo == "")
{
button1.disabled = true;
}
else
{
button1.disabled = false;
}
Please use the [code] tags when posting code/html it makes it much easier to read
Never argue with fools, they will only drag you down to their level, and beat you with experience.
Q: How do you tell an experienced hacker from a novice?
A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|