View Full Version : java script enable/disable link
Findq
10-12-2002, 12:47 PM
hello,
My query is
How to enable/disable link which is on form when changes in
Textfield?
i.e I want to enable link when changes in Textbox....
reply asap
See if you can work with the following
<SCRIPT>
<!--
function chk(){
if (document.form1.t1.value=='')
document.form1.button.disabled=true
else{
document.form1.button.disabled=false
}
if (document.all)
setTimeout("chk()",100)}
setTimeout("chk()",500)
// -->
</SCRIPT>
<FORM name=form1><P><INPUT type=text name=t1>
<INPUT type=submit value=Submit name=button>
<INPUT type=reset value=Reset>
</FORM>
adios
10-12-2002, 05:29 PM
You did say 'link' - right?
<html>
<head>
<title>untitled</title>
<script type="text/javascript" language="javascript">
function link_enable(link) {
if (typeof link.disabled != 'undefined') link.disabled = false;
link.onclick = null;
}
</script>
</head>
<body>
<form>
<input name="t1" type="text" onchange="link_enable(document.links[0])" />
<a href="http://www.codingforums.com" onclick="return false" disabled="disabled">LINK</a>
</body>
</html>
Findq
10-14-2002, 09:29 AM
Hello,
if there r three links on the form then how to
check for 2nd link..how to pass 2nd link is
as a parameter...
glenngv
10-14-2002, 09:36 AM
link_enable(document.links[1])
This is an array containing references to all link objects in the document. The index starts at 0.
Findq
10-14-2002, 11:24 AM
thanks...
there r two links.
I wrote alert in both link onclick event and I disabled
second link by using above link_enable(link[1]) function..
but my query is...
if I clicked on first link, message is shown and second link
become enabled..why this happened....why second link
is not disabled till we close the form.......
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.