Click to See Complete Forum and Search --> : basic function help
bddosch
05-08-2003, 07:38 AM
----------------
<script language="JavaScript">
<!--
function SetText(obj,text) {
document.Form.obj.value = text;
}
//-->
</script>
----------------
<form name="Form" method="post" action="">
<input type="text" name="textfield" onClick="SetText('textfield','halo')">
</form>
this is my question:
SetText(obj,text)
refers to
document.Form.obj.value = text;
how do i get the
document.Form.obj.value = text;
from
SetText(obj,text)
khalidali63
05-08-2003, 07:41 AM
If you mean how to see whats already in the text field or after the value is updated.just put an alert statement .
alert(document.Form.obj.value )
bddosch
05-08-2003, 07:44 AM
I want to make the obj field dynamic, so that the code could be used for more than one field.
so the (obj) has the value of "textfield" -(from my onClick string)
Try this out... Note the fact that we are using this to reference the form object. This way, it can dynamically reference multiple objects.
<html>
<head>
<script language="javascript" type="text/javascript">
function SetText(obj,val) {
obj.value = val;
}
</script>
</head>
<body>
<form name="Form" method="post" action="">
<input type="text" name="textfield" onClick="SetText(this,'halo')">
</form>
</body>
</html>
bddosch
05-08-2003, 09:33 AM
thanks pal, that works fine, but now the problem is this:
function FxTotal(box,radio) {
var fxtotalamount;
if (document.Order.box.checked) {
for (i=0;i<document.Order.radio.length;i++) {
if (document.Order.radio[i].checked) {
fxtotalamount=(document.Order.radio[i].value)
}
<input name="Fxbox" type="checkbox" id="Fxbox" value="checkbox" onClick="FxTotal('Fxbox','Fx')">
<input name="Fx" type="radio" value="16.64" onclick="FxTotal('Fxbox','Fx')" checked>
<input type="radio" name="Fx" value="33.28" onclick="FxTotal('Fxbox','Fx')">
<input type="radio" name="Fx" value="66.56" onclick="FxTotal('Fxbox','Fx')">
I want the values from the checkbox and radio buttons to be displayed in the java function.