/    Sign up×
Community /Pin to ProfileBookmark

Activate/deactivate textfield

Hello

I have a form where a radiobutton should be linked to a textfield i.e if current radiobutton is checked then should the textfield on the same row be activated and all other textfields in current form should be deactivated at the same time that their values should be set to NULL is that possible? if yes how do I do that?

I post some syntax for my form below:
——————————————————————–

<form action=”m2.pl” method=”post” name=”form1″>
<table cellpadding=”0″ cellspacing=”0″>
<tr>
<td width=”5″>&nbsp;</td>
<td width=”5″>&nbsp;</td>
<td width=”110″>&nbsp;</td>
<td width=”5″ align=”center”>&nbsp;</td>
<td width=”281″>&nbsp;</td>
</tr>
<tr>
<td width=”5″> <input name=”m2″ type=”radio” value=”1″ checked> </td>
<td width=”5″>&nbsp;</td>
<td width=”110″>&nbsp;</td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>Avaktivera</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”2″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″> <input name=”m2nr2″ type=”text” id=”m2nr2″> </td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”3″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr3″ type=”text” id=”m2nr3″></td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”4″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr4″ type=”text” id=”m2nr4″></td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”5″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr5″ type=”text” id=”m2nr5″></td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”6″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr6″ type=”text” id=”m2nr6″></td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”7″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr7″ type=”text” id=”m2nr7″></td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”8″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr8″ type=”text” id=”m2nr8″></td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”9″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr9″ type=”text” id=”m2nr9″></td>
<td width=”5″ align=”center”>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td width=”5″><input type=”radio” name=”m2″ value=”10″></td>
<td width=”5″>&nbsp;</td>
<td width=”110″><input name=”m2nr10″ type=”text” id=”m2nr10″></td>
.
.
.
.
.

.
———————————————————————–

Thanks in advance!

/D_S

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JMay 03.2005 — Not too sure here but this might point you in the right direction

[SIZE=1]

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>



<script type="text/javascript">

<!--



function chk_rad(){

myForm=document["form1"]



for(var i=1;i<myForm["m2"].length;i++){



myForm["m2nr"+i].disabled=false

myForm["m2nr"+i].value=null



if(myForm.m2[i].checked){

myForm["m2nr"+i].value=""

}

else{

myForm["m2nr"+i].disabled=true

}



}



}



//-->

</script>

</HEAD>

<BODY>

<form action="m2.pl" method="post" name="form1">

<table cellpadding="0" cellspacing="0">

<tr>

<td width="5">&nbsp;</td>

<td width="5">&nbsp;</td>

<td width="110">&nbsp;</td>

<td width="5" align="center">&nbsp;</td>

<td width="281">&nbsp;</td>

</tr>

<tr>

<td width="5"> <input name="m2" type="radio" value="1" checked> </td>

<td width="5">&nbsp;</td>

<td width="110">&nbsp;</td>

<td width="5" align="center">&nbsp;</td>

<td>Avaktivera</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="2" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr1" type="text" id="m2nr1"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="3" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr2" type="text" id="m2nr2"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="4" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"> <input name="m2nr3" type="text" id="m2nr3"> </td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="5" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr4" type="text" id="m2nr4"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="6" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr5" type="text" id="m2nr5"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="7" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr6" type="text" id="m2nr6"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="8" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr7" type="text" id="m2nr7"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="9" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr8" type="text" id="m2nr8"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

</table>

<form>

</BODY>

</HTML>



[/SIZE]
Copy linkTweet thisAlerts:
@digital_stormauthorMay 03.2005 — Edited

My misstake I have solved it.....thank you very much!

Best Regards /D_S


-------old message---------------------------------------

Hello

Thanks .....I get an error that says that 'myForm[...] is null or not an object' indicated below with =====>



------------------------------------------------
<script language="javascript">

function setEnable(idkey)

{

myForm=document["form2"];

for(var i=1;i<myForm["m2"].length;i++){

--------error-----------------------------

======> myForm["m2nr"+i].disabled=false;
-----------------------------------------


myForm["m2nr"+i].value=null;

if(myForm.m2[i].checked){

myForm["m2nr"+i].value="";

}

else{

myForm["m2nr"+i].disabled=true;

}



}



}



//-->

</script>
--------------------------------------



Not too sure here but this might point you in the right direction



[SIZE=1]

<HTML>

<HEAD>

<TITLE>Document Title</TITLE>



<script type="text/javascript">

<!--



function chk_rad(){

myForm=document["form1"]



for(var i=1;i<myForm["m2"].length;i++){



myForm["m2nr"+i].disabled=false

myForm["m2nr"+i].value=null



if(myForm.m2[i].checked){

myForm["m2nr"+i].value=""

}

else{

myForm["m2nr"+i].disabled=true

}



}



}



//-->

</script>

</HEAD>

<BODY>

<form action="m2.pl" method="post" name="form1">

<table cellpadding="0" cellspacing="0">

<tr>

<td width="5">&nbsp;</td>

<td width="5">&nbsp;</td>

<td width="110">&nbsp;</td>

<td width="5" align="center">&nbsp;</td>

<td width="281">&nbsp;</td>

</tr>

<tr>

<td width="5"> <input name="m2" type="radio" value="1" checked> </td>

<td width="5">&nbsp;</td>

<td width="110">&nbsp;</td>

<td width="5" align="center">&nbsp;</td>

<td>Avaktivera</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="2" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr1" type="text" id="m2nr1"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="3" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr2" type="text" id="m2nr2"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="4" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"> <input name="m2nr3" type="text" id="m2nr3"> </td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="5" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr4" type="text" id="m2nr4"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="6" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr5" type="text" id="m2nr5"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="7" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr6" type="text" id="m2nr6"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="8" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr7" type="text" id="m2nr7"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

<tr>

<td width="5"><input type="radio" name="m2" value="9" onclick="chk_rad()"></td>

<td width="5">&nbsp;</td>

<td width="110"><input name="m2nr8" type="text" id="m2nr8"></td>

<td width="5" align="center">&nbsp;</td>

<td>&nbsp;</td>

</tr>

</table>

<form>

</BODY>

</HTML>



[/SIZE]
[/QUOTE]
×

Success!

Help @digital_storm spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...