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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript method?

Status
Not open for further replies.

zzfive03

Programmer
Jun 11, 2001
267
Lets say I have a radio button, and when I click it, i want my focus to be on a <input type='text'> box. But lets say I have a value in the input such as:
<input type='text' value='Type Data Here'>

When I click the Radio button, I want the value inside the text box to apper highlighted.

Can this be done?
Thank you in advance.
 
<script language=javascript
function Changetxt(theField)
{
if (theField.value==1)
{
txtValue.style.color=&quot;red&quot;
}else
{
txtValue.style.color=&quot;black&quot;
}
return true
}
</script>
<input type=text name=&quot;txtValue&quot; value=&quot;test&quot;>
<input type=radio onclick=&quot;Changetxt(this)&quot; value=&quot;1&quot;>option
<input type=radio onclick=&quot;Changetxt(this)&quot; value=&quot;2&quot;>option
 
thanks SarkMan,

But rather than just change the color, i actualy want the focus to be on the text, and the text highlighted. This way, when the user clickes the radio button, he/she can just type their own value into the box, and not have to worry about clicking the box, highlighting the 'Place Text Here' and first removing it before entering their own data.

ZZ
 
Change the javascript to
function Changetxt(theField)
{
//alert(theField.value)
if (theField.value==1)
{
txtValue.focus();
txtValue.select();

}else
{

}
return true
}
 
how would you do a select() fuction on VBScript?
 
.. and why would you want to? ..
(client-side VBScript a no-no) codestorm
Fire bad. Tree pretty. - Buffy
Hey, I'm operating on a limited mental budget here.
<insert witticism here>
 
Here is the function in vbscript
<script language=vbscript>
function Changetxt(theField)
txtValue.focus()
txtValue.select()
msgbox (&quot;hello&quot;)

End function
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top