cmattoon Posted July 4, 2011 Share Posted July 4, 2011 I have a checkbox with an ID and NAME of "noexpire", and a Spry textbox with an ID and NAME of "expiration". When the user checks the "noexpire" checkbox, I want the date "12/31/2099" to automatically populate the textbox. I've tried several different arrangements of: document.frmPass.expiration document.getElementById('expiration') document.getElementById("expiration") as well as a few others, but for some reason, nothing appears to work. I'm not even getting a JavaScript error! (I've also tried ".value" for both the checkbox and textbox..) I tried an alert box, and the function is being accessed, but it won't do anything. function doExpire(){ document.getElementsByName("expiration").text=(document.getElementByName("noexpire").checked)?"12/31/2099":""; } Any ideas? Thanks! Quote Link to comment Share on other sites More sharing options...
Adam Posted July 5, 2011 Share Posted July 5, 2011 You need to set the value property, not text. The reason you're not getting a JS error is because you're creating a new property. Quote Link to comment Share on other sites More sharing options...
Amit20 Posted July 8, 2011 Share Posted July 8, 2011 try this document.getElementsByName("expiration").text.value=(document.getElementByName("noexpire").checked)?"12/31/2099":""; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.