PDA

View Full Version : change textfields readyonly


Rayzer
11-08-2014, 10:34 PM
hi,

I have a form with several textfields.

I have questions :confused:

1) I have textfield A and textfield B which are questions about %, if the user enters 70 onto box A i need box B to auto fill 30?

2) If the user enters any value less the 100 into box A, I need boxes C,D,E to change from readyonly and Greyed out to active for the user to enter other details??

Dreamweaver cs6.

edbr
11-08-2014, 11:43 PM
Use JavaScript and write a function using a calculation and call it using onchange

Rayzer
11-09-2014, 10:22 PM
Use JavaScript and write a function using a calculation and call it using onchange

Thanks for the reply edbr, the problem is i am a complete noob!
Yes i can use Dreamweaver, but that's about it! What you say makes sense but i would not know where to start.

Any more help would be grateful;)

edbr
11-10-2014, 02:04 AM
you will have to look at javascript tutorials theres plenty around
below is a mash up to show haw values van be changed as a starter for you it uses onBlur so is fired as you leave the first field<HTML>
<HEAD>
<TITLE>Javascript Form Calculation</TITLE>

<SCRIPT language="JavaScript">

function Calculate()



{
if (myform.Cost1.value < 100)


myform.Cost1.value = 100- myform.Qty1.value;





if (myform.Cost1.value > 1)

myform.Cost2.value = myform.Cost1.value;

myform.Subtotal.value = parseFloat(myform.Cost1.value)
+ parseFloat(myform.Cost2.value);
}

</SCRIPT>
</HEAD>

<BODY>
<FORM NAME="myform"><P>

<TABLE BORDER="1" WIDTH="35%" >

<TR>
<TD width="53%">number</TD>
<TD width="16%">

<CENTER>
<P><INPUT TYPE="TEXT" NAME="Qty1" SIZE="5"
onBlur="Calculate();">
</CENTER>


</TD>
<TD width="17%">
<CENTER>
</CENTER>
</TD>

<TD width="14%"><INPUT TYPE="TEXT" NAME="Cost1" SIZE="8"></TD>
</TR>


<TR>
<TD>remainder</TD>
<TD>
<CENTER>
<P>
<input type="TEXT" name="Cost2" size="8">
</CENTER>
</TD>
<TD>
<CENTER>
<P>
</CENTER>
</TD>
<TD>&nbsp;</TD>
</TR>


</TABLE>

</FORM>

</BODY>

</HTML>

Ricky55
11-10-2014, 12:21 PM
To grey out you use:-

<input type="text" disabled>