Make data enter into two fields at the same time...?

D

dbuschmohle

Hello,
I'm trying to figure out a way to pass data from one field into another
without having to type it twice....

Take a look at the code below... If you can past it into a blank page
and view it, you'll see what I'm trying to make...


<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>test</title>
</head>

<body bgcolor="#C0C0C0">
<div align="center"></p>



<!-- Search Google -->
<FORM method=get action="http://www.google.com/search" target="_blank">
<INPUT type=text name=q size=25 maxlength=255><p>
<INPUT type=submit name=button VALUE="google"></p></FORM>
<!-- Search Google -->

</p>
<p>&nbsp;</p>

<!-- Search Yahoo -->
<FORM method=get action="http://search.yahoo.com/search"
target="_blank">
<INPUT type=text name=p size=25 maxlength=255><p>
<INPUT type=submit name=button VALUE="yahoo"></p></FORM>
<!-- Search Yahoo -->


<p>&nbsp;</div>
<p align="center">&nbsp;</p>
</body>
</html>
 
J

Jon Spivey

Hi,
If you make the text box in the Google form like this
<INPUT type=text name=q onchange="document.forms[1].p.value=this.value"
size=25 maxlength=255>
it will copy whatever's typed into the google form into the yahoo form
 
D

dbuschmohle

Thanks Jon...

How would I carry it to more then one field...? See below...

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
<title>test</title>
</head>

<body bgcolor="#C0C0C0">
<div align="center"></p>



<!-- Search Google (1) -->
<FORM method=get action="http://www.google.com/search" target="_blank">
<INPUT type=text name=q size=25
onchange="document.forms[1].p.value=this.value" maxlength=255><p>
<INPUT type=submit name=button VALUE="Google"></p></FORM>
<!-- Search Google (1) -->

</p>
<p>&nbsp;</p>

<!-- Search Yahoo (2) -->
<FORM method=get action="http://search.yahoo.com/search"
target="_blank">
<INPUT type=text name=p size=25 maxlength=255><p>
<INPUT type=submit name=button VALUE="Yahoo"></p></FORM>
<!-- Search Yahoo (2) -->

</p>
<p>&nbsp;</p>

<!-- Search eBay (3) -->
<FORM method=get action="http://search.ebay.com/search/search.dll"
target="_blank">
<INPUT type=text name=satitle size=25 maxlength=255><p>
<INPUT type=submit name=button VALUE="eBay"></p></FORM>
<!-- Search eBay (3) -->



<p>&nbsp;</div>
<p align="center">&nbsp;</p>
</body>
</html>
 
J

Jon Spivey

Like this - assuming every form only has one text field
<script type="text/javascript">
function fillEm(s){
for(i=1;i<document.forms.length;i++){
for(a=0;a<document.forms.elements.length;a++)if(document.forms.elements[a].type=='text')document.forms.elements[a].value=s;}}
</script>
and the Google box like this
<INPUT type=text name=q onkeyup="fillEm(this.value)" maxlength=255>

Make sure the line starting for(a=0 is all on one line. This will stick
whatever you type in the google box into all the other search boxes on the
page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top