Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

show or hide button if field equals X 3

Status
Not open for further replies.

evr72

MIS
Dec 8, 2009
265
US
Hello,

Is there a way to show or hide a button if a field has a specific value?

 
Yes.
:)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
...
...
...
OK, just joking.
Code:
mycontrol.Visible=(myfield=specificvalue)
;-)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
hi.
that's a neat concept.
i tried this, and it didn't work. am i doing something wrong?
Code:
<form name="form1" id="form1">
<input type="text" name="myfield" id="myfield" value="2">
</form>
<br>
<input name="mycontrol" id="mycontrol" type="button" value="button" mycontrol.Visible=(myfield="1")></input>
 
I think that is ASP NET and would need to be in an ASP NET page to run, but I'm probably wrong.
 
That is plain HTML. That won't work.
You'll have to do that via Javascript.
Check out forum216


[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
On second thought: you can do this with asp.

like this:
Code:
<%
 If myfield="1" Then
%>
<input name="mycontrol" id="mycontrol" type="button" value="button"></input>
<%
 End If
%>

;-)

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
[tt]<form name="form1" id="form1">
<input type="text" name="myfield" id="myfield" value="2" [blue]onblur="this.form.mycontrol.style.display=(this.value=='1')?'block':'none';"[/blue]>
[red]<!--[/red] </form> [red]-->[/red]
<br>
<input name="mycontrol" id="mycontrol" type="button" value="button" [blue]style="display: none;"[/blue]></input>
[red]</form>[/red][/tt]
 
Just seen something - this won't work either!
I thought you were referring to some variable but you are actually referring to a "live" field!
==>You need to submit that form before reading its value!
Code:
<form name="form1" id="form1">
<input type="text" name="myfield" id="myfield" value="2" [b] onchange="this.form.submit()"[/b]>
<br>
<input name="mycontrol" id="mycontrol" type="button" value="button" mycontrol.Visible=[b][red]<%=(Request.Form("myfield")="1")%>[/red][/b]></input>
</form>

.

[navy]"We had to turn off that service to comply with the CDA Bill."[/navy]
- The Bastard Operator From Hell
 
tsuji,
thanks so much.
i tried it. it works now. i see where i put the form tag in the wrong place.
cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top