...

View Full Version : Is It Possible To Enter A Term In A Text Field, Hit A Button, & Have That Text...



Dan6971
01-10-2004, 10:10 PM
Is It Possible To Enter A Term In A Text Field, Hit A Button, & Have That Text Populate The Text Fields In Other Forms...???

Oakendin
01-10-2004, 11:52 PM
You can use the script I developed for this post:
http://www.codingforums.com/showthread.php?s=&threadid=18868

Dan6971
01-11-2004, 03:12 AM
Thanks for replying...

Let me be more clear on what I would like to accomplish (if doable)...

I would like to do something similar to a form that populates the same fields in "Shipping Address" as in "Billing Address"...

However, here is what I would like to do:

All On One Page"


SEARCH: |__________________| [ENTER]

(When [ENTER] is pressed, separate fields in separate forms all populate the same search term.)


For example:

SEARCH: |The Beatles | [ENTER]


(The following, separate forms show up like this:

SEARCH 2: |The Beatles | [ENTER]
SEARCH 3: |The Beatles | [ENTER]
SEARCH 4: |The Beatles | [ENTER]


Any ideas? Is this possible? Can two forms act together on one page?



Thanks,
Dan

Willy Duitt
01-11-2004, 03:34 AM
There are many ways to do this.
Here is an example of one way:

<script type="text/javascript">
function popSearch() {
d = document;
var search = d.forms[0].S1.value;
d.forms[1].S2.value = search;
d.forms[2].S3.value = search;
}
</script>
</HEAD>

<BODY>
<form>
Search 1<input type="text" name="S1">
<input type="button" value="Enter" onclick="popSearch()">
</form>
<form>
Search 2<input type="text" name="S2">
</form>
<form>
Search 3<input type="text" name="S3">
</form>

.....Willy

Dan6971
01-11-2004, 03:37 AM
Willy! You freaking genius! ;-)


Can you please help me to get it to work on this site, please...?


Click Here! (http://www.pianomanfan.com/Test.html)


Also, how can I get the "Go" to open in a new page?


Thanks!
Dan

Dan6971
01-11-2004, 04:05 PM
Willy (or anyone else)? Are you still here? Please help me with my dilemma - you seem to know a lot about what you speak...

I would love to be able to take the 2nd and 3rd search boxes and add them to 2 other searches, which can each, independently, search and go to another site.


Click Here To Better Understand... (http://www.PianoManFan.com/Test.html)


Thanks,
Dan

Dan6971
01-12-2004, 03:26 AM
Willy (or anyone)...

Check Out This Awesome Coding! (http://www.pianomanfan.com/Test.html)

I got it to work, the way that I want, however, my first search uses an "Input Name" - "SEARCH" - but what do I do if my second search uses some other term?

How can I get it to be dynamic?


THANKS,
Dan

glenngv
01-12-2004, 06:45 AM
You have to specify each name in an array.


function UpdateFormSearchFields(frm,val){
var fields = new Array("search","query","key","q"); //search field names
var len = fields.length;
for(var n=0;n<len;n++){
if (frm.elements[fields[n]]) frm.elements[fields[n]].value = val;
}
}
}

Dan6971
01-12-2004, 02:36 PM
Thanks, Glenn...

Now, I can get the searches to search properly, however, my third search will not populate with the search term added to the search at the top of the page, as the other searches do - please help...

CLICK HERE (http://www.PianoManFan.com/Test.html)


Thanks,
Dan

Dan6971
01-13-2004, 01:06 AM
Does anyone know? Can anyone help me???


Thanks,
Dan

glenngv
01-13-2004, 01:17 AM
You didn't use the solution I posted


function UpdateFormSearchFields(frm,val){
var fields = new Array("search","more"); //search field names
var len = fields.length;
for(var n=0;n<len;n++){
if (frm.elements[fields[n]]) frm.elements[fields[n]].value = val;
}
}
}

As you add more search fields with different names, you just add them in the array and that's it! The code will still work.

Dan6971
01-13-2004, 01:53 AM
Glenn...

Thank you for replying.

I did add the code to this page (http://www.PianoManFan.com/Test2.html) but it does not populate my searches...

I am not really good at this - so I may not have done it the same way. Can you just take the code from my page and please post it all here or post it on one of your webpages for me to get it from?


Thank you so much, Glenn...



Dan

glenngv
01-13-2004, 02:04 AM
If you just bothered to use the function I posted as is and replacing yours, then it would work.

Dan6971
01-13-2004, 02:11 AM
Glenn...

Let me say that you are really great at this stuff!


OK, so I use your code:

function UpdateFormSearchFields(frm,val){
var fields = new Array("search","more"); //search field names
var len = fields.length;
for(var n=0;n<len;n++){
if (frm.elements[fields[n]]) frm.elements[fields[n]].value = val;
}
}
}


And I replace this part of my code:

function UpdateFormSearchFields(frm,val){
var fields = frm.getElementsByTagName("input");
var len = fields.length;
for(var n=0;n<len;n++){
var field = fields[n];
if(field.type=="text" && field.name.indexOf("search")>-1){
field.value = val;
}
}
}


I'm sorry if I don't understand. Do I need to replace more of my code or just the second part of that function? I am confused.


Thanks 1000000000000000%,
Dan

glenngv
01-13-2004, 02:42 AM
Glad I could be of help to you. :)
No need to replace other codes.
If in the future you add more search fields with names other than those in the array, then you need to add them.
If you also use that function in other pages with different search field names, then you need to modify the array accordingly.

Dan6971
01-13-2004, 02:45 AM
Thanks so much Glenn.

Is there a place that you could post the code the way that my code should be?

I am uncertain as to how it should be. What part of my code do I omit/change - or do I just add those search terms to the array?

Please be patient with me - I am not close to being good at this - as you are...


THANKS!!!!!!!!!!!!
Dan

glenngv
01-13-2004, 02:55 AM
You just replace the whole UpdateFormSearchFields() function with my version. That's it.

Dan6971
01-13-2004, 03:23 AM
Glenn...

I changed the font on a test/local page and it caused my automatic fill feature to not work, so I left it the same on the web version.

Did you actually create this on a page? If so, is it located on the web or could you e-mail me the code?



Thanks so much!!!!!!!!
Dan

glenngv
01-13-2004, 03:47 AM
Ok, sorry I had a syntax error in the function I posted.
There is an extra close brace

Here is the modified function:


function UpdateFormSearchFields(frm,val){
var fields = new Array("search","more"); //search field names
var len = fields.length;
for(var n=0;n<len;n++){
if (frm.elements[fields[n]]) frm.elements[fields[n]].value = val;
}
}

Dan6971
01-13-2004, 03:53 AM
GLENN!!! YOU F*CKING GENIUS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



THANKS!!!
Dan

Dan6971
01-13-2004, 03:55 AM
Now Glenn...

How can I have the searches open a new window, rather than opening in the same window? Can I change it from "_top" to "_new" (for all of the searches)...?



THANKS!!!!!!!!
Dan

glenngv
01-13-2004, 04:04 AM
The script error notification is probably turned off that's why you didn't see the syntax error.

Regarding the new window...
Since you do submit the form when the Go or Search button is clicked, you just add a target attribute in all your forms.

<form target="_blank" ...>

I recommend using an input type=image to make an image submit button instead of using a hyperlink and doing a submit via javascript.

<input type="image" name="Go" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21" border="0" alt="">

Dan6971
01-14-2004, 07:11 AM
OK, now everything works, but when I start to type in the first TEXT BOX, my status bar says: "Error on page"...

Any ideas?


Thanks,
Dan

glenngv
01-14-2004, 07:43 AM
As I pointed out earlier, enable the javascript error notification to see the details of the error.

Tools / Internet Options / Advanced / Display a notification after every script error

Or simply double-click the exclamation icon in the status bar.
If you're using Mozilla, open the Javascript console - Tools / Web development / Javascript console

Dan6971
01-14-2004, 07:58 AM
It says that "ns6" is undefined, in this line:

eventobj=ns6? e.target : event.srcElement


???????


Thanks,
Dan

glenngv
01-14-2004, 08:13 AM
You missed the declaration of ns6 variable in Test.html page.
See the Test2.html page, it's ok there.

There is a better solution, though.

eventobj=(event) ? event.srcElement : e.target

Dan6971
01-14-2004, 03:33 PM
How do I declare the "ns6" variable?

I replaced:

eventobj=ns6? e.target : event.srcElement

...with...

eventobj=(event) ? event.srcElement : e.target

...but both Test.html and Test2.html are not working... :confused: :(

What can I do? (This is weird.)


THANK YOU!
Dan

glenngv
01-15-2004, 01:50 AM
Your test pages seem to be fixed already

http://www.pianomanfan.com/Test.html
http://www.pianomanfan.com/Test2.html

Dan6971
01-15-2004, 02:23 AM
They seem to be working, however, how can I add a "Clear Text" function to the first TEXT BOX?

I was trying before, but I was unsuccessful...


Thanks,
Dan

glenngv
01-15-2004, 04:21 AM
like this?

<form onKeyUp="highlight(event)" onClick="clearText(this)">
<input name="S1" type="text" size="50" style="background-color:#CCFF99;">
<input type="button" value="Add To All Searches" onclick="popSearch(this.form)">
<input type="button" value="Clear Text" onclick="this.form.S1.value=''">
</form>

Dan6971
01-15-2004, 05:02 AM
Genius Again!!!

Now, on the page I am building ( CLICK HERE (http://www.PianoManFan.com/Test2.html) ) a couple of the tables are getting an extra row/space beneath the actual parts of the table that count.

Also, how can I use images for buttons in my main search?

Check it out for me, please...



Thanks!!!!!!!!!!!!!!!!!!!!!!!!
Dan

glenngv
01-15-2004, 05:57 AM
<form> is a block element.
make it inline by putting this in the style tag

form {display:inline}

Dan6971
01-15-2004, 06:29 AM
Where exactly do I place that code?

Also, on all, but my E-MAIL TABLE, the mouse does not change to a finger when placed on the "GO" image - why is that and how can I fix that?


Thanks SOOOOOOOOOOOOOOO Much,
Dan

glenngv
01-15-2004, 06:49 AM
Originally posted by glenngv
<form> is a block element.
make it inline by putting this in the style tag

form {display:inline}

The mouse doesn't change to a pointer because you didn't make the image as hyperlink the same way as you did on the other Go buttons.

Dan6971
01-15-2004, 02:31 PM
Awesome!

It all works now!!!

Check It Out!!! (http://pianomanfan.com/Test2.html)

Now, how can I change the "Submit" type buttons ("Add To All Searches" & "Clear Text") in the MAIN SEARCH to be graphics?



THANKS!!!
Dan

Garadon
01-15-2004, 03:34 PM
<form name="FORMNAME" onsubmit="alert();">
<input type="Image" src="PICTURE" onclick="document.FORMNAME.submit();">
</form>

Dan6971
01-15-2004, 03:55 PM
I am having trouble using your code, with my code:

<TABLE width="480" border="8" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#000000">
<tr>
<td><form onKeyUp="highlight(event)" style="{display:inline}" class="one">
<input name="S1" type="text" style="background-color:#CCFF99;" value="Start Here" size="40" onFocus="clearText(this)">
<input type="button" value="Add To All Searches" onclick="popSearch(this.form)">
<input type="button" value="Clear Text" onclick="this.form.S1.value=''">
</form></td>
</tr>
</table>

What should it look like with your code?



Thanks soooooooo much!!!
Dan

Garadon
01-15-2004, 05:06 PM
remember to replace "IMAGE_URL" with appropriate urls

<TABLE width="480" border="8" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#000000">
<tr>
<td><form onKeyUp="highlight(event)" style="{display:inline}" class="one">
<input name="S1" type="text" style="background-color:#CCFF99;" value="Start Here" size="40" onFocus="clearText(this)">
<input type="Image" src="IMAGE_URL" onclick="popSearch(this.form)">
<input type="Image" src="IMAGE_URL" onclick="this.form.S1.value=''">
</form></td>
</tr>
</table>

Dan6971
01-15-2004, 05:22 PM
Here is what I used, but it didn't work right... :(

<TABLE width="480" border="8" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#000000">
<tr>
<td><form onKeyUp="highlight(event)" style="{display:inline}" class="one">
<input name="S1" type="text" style="background-color:#CCFF99;" value="Start Here" size="40" onFocus="clearText(this)">
<input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21" onclick="popSearch(this.form)">
<input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21" onclick="this.form.S1.value=''">
</form></td>
</tr>
</table>


Thank you!!!
Dan

Dan6971
01-15-2004, 07:42 PM
Garadon?

Dan6971
01-16-2004, 05:56 AM
???

Dan6971
01-17-2004, 05:58 AM
Anyone?

Garadon
01-17-2004, 10:38 AM
how about this?


<TABLE width="480" border="8" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#000000">
<tr>
<td><form onKeyUp="highlight(event)" style="{display:inline}" class="one">
<input name="S1" type="text" style="background-color:#CCFF99;" value="Start Here" size="40" onFocus="clearText(this)">
<input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21" onclick="popSearch(this.form);return false;">
<input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21" onclick="this.form.S1.value='';return false;">
</form></td>
</tr>
</table>

Dan6971
01-17-2004, 03:46 PM
Garadon...

Now, I have graphics in the TEXT Field, so I used this code, but it didn't work... :-( PLEASE HELP ME... I am so bad at this. :(




<TABLE width="520" border="8" cellpadding="0" cellspacing="0" bordercolor="#000000" bgcolor="#000000">
<tr>
<td height="21"><font size="3" face="Verdana, Arial, Helvetica, sans-serif"><strong>Super
Search</strong></font></td>
</tr>
<tr>
<td height="26"><form onKeyUp="highlight(event)" style="{display:inline}" class="one">
<input name="S1" type="text" style="background: #CCFF99;background-image: url('http://www.pianomanfan.com/LootTool/TextField2.gif'); background-repeat: no-repeat;" size="40" onMouseOver="window.status='Enter Search'; return true"
onMouseOut="window.status='';return true" onFocus="this.value='';this.style.background='#CCFF99'">
<input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21" onclick="popSearch(this.form);return false;">
<input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21" onclick="this.form.S1.value='';return false;">
</form></td>
</tr>
</table>




THANK YOU!!!!!!!!!!

Willy Duitt
01-17-2004, 09:24 PM
An <input type="image"> is the same as <input type="submit">
And therefore will submit the form when clicked. Unless your form action
or onsubmit event handler account for the popSearch() function.
The form will be submitted without firing the function.

Try this:

<a href="#" onclick="popSearch(this.form);return false;">
<input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21"></a>

.....Willy

Dan6971
01-17-2004, 10:28 PM
Willy... You almost got it, I think... It gave me "Errors On Page" and add: "...x=9&y=14..." to the URL - why is that?

Here is the code I used:




<form onKeyUp="highlight(event)" style="{display:inline}" class="one">
<input name="S1" type="text" style="background: #CCFF99;background-image: url('http://www.pianomanfan.com/LootTool/TextField2.gif'); background-repeat: no-repeat;" size="40" onMouseOver="window.status='Enter Search'; return true"
onMouseOut="window.status='';return true" onFocus="this.value='';this.style.background='#CCFF99'">
<a href="#" onclick="popSearch(this.form);return false;"><input type="Image" src="http://www.PianoManFan.com/Affiliates/Go.gif" width="21" height="21"></a>
<input type="button" value="Clear Your Text" onclick="this.form.S1.value=''">
</form>





Thank you,
Dan

Dan6971
01-17-2004, 10:29 PM
Also, my "SUPER SEARCH" is now not working - how come?


Dan

Dan6971
01-17-2004, 11:10 PM
On this page, when someone clicks my first or second search without entering any terms, the URL changes to something like:

http://pianomanfan.com/Test2.html?email=&button.x=20&button.y=7

Why is that? How can I add an alert that says, "if empty, then alert user"? How can I do that?

Click Here For The Site (http://pianomanfan.com/Test2.html)


Thanks,
Dan

Willy Duitt
01-18-2004, 12:17 AM
Sorry when asking for help you should remove your scripts which
disable my browsers functionality. I lost interest when I got here.

<script language=JavaScript>
<!--

var message="";
///////////////////////////////////
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers)
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")
// -->
</script>

Perhaps someone else will come along and not mind wading thru the drivel.

Sorry;
.....Willy

Dan6971
01-18-2004, 01:43 AM
C'mon Willy...

I just disabled the right-clicking.

Please help - you're one of the best at this...

I can remove the code, if you'll help me again.

What do you say?

(Sorry about the code, I didn't even realize it was there, since it was on my other pages, from my other site...)


Thank you,
Dan

Dan6971
01-18-2004, 03:46 AM
Willy... I took it out, please help. It's all messing up... :(

glenngv
01-19-2004, 09:23 AM
You keep littering this forum with similar threads (http://www.codingforums.com/showthread.php?s=&threadid=31731). Stick to one discussion as much as possible.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum