Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

change value of a text box using an option button

Status
Not open for further replies.

ABinBoston

Programmer
Nov 6, 2001
22
US
I have an asp page where a user enters a service call. On the page is an option group saying system down - yes/no using radio buttons. Also on the page is a textbox named "timedown" for time.

When the user clicks "yes" I'd like to set the value of "timedown" to the current time.

Thanks! - Anthony
 
Use a bit of javascript.

Add an onclick event to the radio buttons and a function which gets the current time and sets the value property of the textbox to the time.

If you do this in ASP you'll have a wasted trip to the server. I suggest you repost this in the javascript forum.
 
Here's a quick example:


<Script Language=&quot;Javascript&quot;>
<!--
function cTime()
{
var date = new Date();
var d = date.getDate();
var day = (d < 10) ? '0' + d : d;
var m = date.getMonth() + 1;
var month = (m < 10) ? '0' + m : m;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

document.frmTest.txtTimeDown.value = (month + &quot;/&quot; + day + &quot;/&quot; + year);
}
//-->
</Script>


<Form name=&quot;frmTest&quot;>
<INPUT type=&quot;text&quot; id=&quot;txtTimeDown&quot; name=&quot;txtTimeDown&quot;>
<br>
<INPUT type=&quot;radio&quot; id=radio1 name=radio1 onclick=&quot;cTime();&quot;>
</Form>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top