Jump to content

Displaying a variable in a text box


badge
 Share

Recommended Posts

Hi all, need a hand,I've defined a variable "sonic" with radio buttons and can display it using

<input type="button" value=Display onClick="document.write(sonic)">

However, I'd really like to show it in a text box next to the button (currently get taken to a new page), and can't for the life of me work out how.Any help greatly appreciated, Badge.

Link to comment
Share on other sites

<script type="text/javascript">var sonic = 'something';</script>...<input type="button" value=Display onClick="document.getElementById('txt1').value = sonic"/><input type="text" id="txt1" value=""/>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...