Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > radio button make text field equal value of form field

Reply
Thread Tools

radio button make text field equal value of form field

 
 
mitch-co2
Guest
Posts: n/a
 
      02-21-2005
What I am trying to do is when someone clicks on the YES radio button I
want the text field called MYTEXT to equal the text field named DATE.

The below code works as long as I do NOT UN-COMMENT the NO radio
button, once I do that it will not work.

Any help would be greatly appreciated.

Mitch



<body>
<script language="JavaScript"><!--
function setField(what) {
if (what.myTick.checked)
what.myText.value = what.date.value;
else
what.myText.value = '';
}
//--></script>

<form>
<p>
Yes <input name="myTick" type="radio" value="Yes"
onClick="setField(this.form)">
<!-- No <input name="myTick" type="radio" value="No"> -->
</p>
<p>sample date
<input type="text" name="date" value="20050202">
auto fill in
<input type="text" name="myText">
</p>
</form>

</body>

 
Reply With Quote
 
 
 
 
McKirahan
Guest
Posts: n/a
 
      02-21-2005
"mitch-co2" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> What I am trying to do is when someone clicks on the YES radio button I
> want the text field called MYTEXT to equal the text field named DATE.
>
> The below code works as long as I do NOT UN-COMMENT the NO radio
> button, once I do that it will not work.
>
> Any help would be greatly appreciated.
>
> Mitch
>
>
>
> <body>
> <script language="JavaScript"><!--
> function setField(what) {
> if (what.myTick.checked)
> what.myText.value = what.date.value;
> else
> what.myText.value = '';
> }
> //--></script>
>
> <form>
> <p>
> Yes <input name="myTick" type="radio" value="Yes"
> onClick="setField(this.form)">
> <!-- No <input name="myTick" type="radio" value="No"> -->
> </p>
> <p>sample date
> <input type="text" name="date" value="20050202">
> auto fill in
> <input type="text" name="myText">
> </p>
> </form>
>
> </body>
>


Will this help? Watch for word-wrap.

<html>
<head>
<title>RadioYes.htm</title>
<script type="text/javascript">
function setField(form,what) {
(what == 1) ? form.myText.value = form.date.value : form.myText.value =
"";
}
</script>
</head>
<body>
<form>
Yes <input name="myTick" type="radio" value="Yes"
onClick="setField(this.form,1)">
No <input name="myTick" type="radio" value="No"
onClick="setField(this.form,0)">
<br>sample date : &nbsp;
<input type="text" name="date" value="20050202">
<br>auto fill in : &nbsp;
<input type="text" name="myText">
</form>
</body>
</html>


 
Reply With Quote
 
 
 
 
mitch-co2
Guest
Posts: n/a
 
      02-22-2005
McKirahan,

Thank you very much for the help...it worked perfectly!

Mitch



McKirahan wrote:
> "mitch-co2" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> > What I am trying to do is when someone clicks on the YES radio

button I
> > want the text field called MYTEXT to equal the text field named

DATE.
> >
> > The below code works as long as I do NOT UN-COMMENT the NO radio
> > button, once I do that it will not work.
> >
> > Any help would be greatly appreciated.
> >
> > Mitch
> >
> >
> >
> > <body>
> > <script language="JavaScript"><!--
> > function setField(what) {
> > if (what.myTick.checked)
> > what.myText.value = what.date.value;
> > else
> > what.myText.value = '';
> > }
> > //--></script>
> >
> > <form>
> > <p>
> > Yes <input name="myTick" type="radio" value="Yes"
> > onClick="setField(this.form)">
> > <!-- No <input name="myTick" type="radio" value="No"> -->
> > </p>
> > <p>sample date
> > <input type="text" name="date" value="20050202">
> > auto fill in
> > <input type="text" name="myText">
> > </p>
> > </form>
> >
> > </body>
> >

>
> Will this help? Watch for word-wrap.
>
> <html>
> <head>
> <title>RadioYes.htm</title>
> <script type="text/javascript">
> function setField(form,what) {
> (what == 1) ? form.myText.value = form.date.value :

form.myText.value =
> "";
> }
> </script>
> </head>
> <body>
> <form>
> Yes <input name="myTick" type="radio" value="Yes"
> onClick="setField(this.form,1)">
> No <input name="myTick" type="radio" value="No"
> onClick="setField(this.form,0)">
> <br>sample date : &nbsp;
> <input type="text" name="date" value="20050202">
> <br>auto fill in : &nbsp;
> <input type="text" name="myText">
> </form>
> </body>
> </html>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet Sharing: Equal upload speeds but un-equal download speeds =?Utf-8?B?TkpU?= Wireless Networking 3 09-15-2007 06:22 AM
Using JS to display value of radio button in text field. PeeZee Javascript 1 10-07-2005 03:32 PM
Pass hidden form field value to another form field to insert in db GavMc ASP General 4 09-22-2005 06:33 PM
Radio button List problem: How to find value of Radio button list's Selected Item using javascript?? Hiten ASP .Net Web Controls 1 05-26-2004 10:32 AM
If value in name field in top row disable submit button until add button is pressed or field is cleared. Chuck Javascript 0 11-10-2003 02:23 AM



Advertisments