I have a JavaScript that I hoped would autofill some fields when a user clicks 
a checkbox, but it doesn't. I will admit I not a JavaScript programmer and 
copied and tweaked some code. The bold areas I edited to try to make it work 
but autofilling with the word "spare", but it doesn't do anything.

Anyone can help here please? Thanks in advance.


<script type="text/javascript" language="javascript">
function setname(box) 
{ 
var f = box.form, b_which = box.checked, from_el, to_el, i = 0;
var fld_name = new Array('lname');
while (from_el = f[fld_name[i]])
{ 
to_el = f[fld_name[i++]];
to_el.value = b_which ? from_el.value : '';
if (to_el.readOnly != null)
to_el.readOnly = b_which ? true : false;
else to_el.onfocus = b_which ? function() {this.blur();
}
: null;
}
}
</script>

<form>

<input name="lname" type="hidden" id="lname" value="Spare">

<input type="checkbox" name="spare" onclick="setname(this)">

Name: <input name="lname" type="text" id="lname">

</form>

Robert O. at HWW


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.4/176 - Release Date: 11/20/2005
 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:224853
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to