Link to home
Start Free TrialLog in
Avatar of macuser777
macuser777Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Can this code be rendered into simple HTML

Hi,

I'm asking this becasue i seem to have some odd browser issues which stop this javascript working on my Safari and IE browsers for mac - thogh it will work on Mozilla

and i never have a problem with more simple HTML

The key is to retain one input box.

Thanks




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>apple+google</title>

<body>
<SCRIPT>
<!--
function copydata() {

    myapple = "0.7.1.0.5.11.1.0.1.4"
    document.google.q.value      = document.myinput.search.value;
    document.apple.myapple.value = document.myinput.search.value;
   
    }
//-->
</SCRIPT>
<form name="myinput">
<input class="text" type="text" name="search" size="20" maxlength="255">
</form>
<form method="get" name="google" onSubmit="return copydata()">
<input type="submit" value="Google Search" onclick="this.form.action=' http://www.google.com/search '">
<input type="hidden" name="q">
</form>
<form method="post" name="apple" onSubmit="return copydata()">
<input type="submit" value="Apple Store" onclick="this.form.action=' http://store.apple.com/1-800-MY-APPLE/WebObjects/AppleStore.woa/71106/wo/tx4tB2eQANCD3J5wviQKzOyvFds/2.0.7.1.0.5.11.1.0.1 ';"><br />
<select name="0.7.1.0.5.11.1.0.1.12">
<option value="0">All </option>
<option value="1">Hardware</option>
<option value="2">Accessory</option>
<option value="3">Software</option>
</select>
<input type="hidden" name="myapple">
</form>
</body>
</html>

Avatar of VincentPuglia
VincentPuglia

Hi,

  I hate to say this, but... what is it the above code is supposed to do?

Vinny
Avatar of macuser777

ASKER

:)

It's just supposed to search google and bring up the results and similarly search the apple store.
The apple search returns an error page i know - but that's a fix for another question. (needs to be sent to home store page first and then post action otherwise request is timed out)

The point of the code is that it allows a get form request (google) and a post  action (request) to
both use the same input box.

let me know if it's still not clear.
! i meant

The point of the code is that it allows a get form request (google) and a post  action request (apple) to
both use the same input box.
I have neither Safari nor the Mac, therefore, I cannot test.  However,  if you cut & paste that code directly from your source -- you do not close the head tag  "</head>"  -- something I presume Safari would freak over (since it freaks over virtually everything.

Also, the above code does not work in IE 6.0 -- it calls google with the search criteria, but never returns to the page (or, did you leave out the iframe where the data is supposed to be returned?)

Vinny

 
ASKER CERTIFIED SOLUTION
Avatar of superslamwich
superslamwich
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>Vinny

>I have neither Safari nor the Mac, therefore, I cannot test.  However,  if you cut & paste that code directly from your source -- you do not close the head tag  "</head>"  -- something I presume Safari would freak over (since it freaks over virtually everything.

-the head tag is closed in my original source - i just cut out some style code to keep the q. short

>Also, the above code does not work in IE 6.0 -- it calls google with the search criteria, but never returns to the page (or, did you leave out the iframe where the data is supposed to be returned?)
- there's no iframe. When you say never returns to the page do you mean on hitting the back button? - maybe another bug
- my Safari and IE for mac just gets as far as this in the address bar

http://www.google.com/search?q=


>Slam

thanks for the revised code but i get the same
- works in Mozilla but in Safari and IE doesn't pick up the keyword for some reason and just returns

http://www.google.com/search?q=

in the address bar.
Errr

>Slam

Its kinda late here...i might be blurring out.... but can you just point out the changes in the script.

macuser
!!!!

elements...

sorry
hmm...  what about adding a "return true" to the end of the function?  I notice you call it with onSubmit="return copydata()"  so maybe it's looking for a return value?...

It is getting late, and I sympathize with  you :-).
>slam

(the clocks went back one hour here today so it's only 2 am!)

Anyway,

i'm afraid i don't follow your last point in terms of code - i've ventured into javascript as it emerged as a way to deal with the one input box problem, though i do understand what you're getting at

If you get time... - but don't don't stay up especially!

Thanks :]
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Tested in IE6.0, NN6.1, Firebird

Vinny
Vinny,

Same again i'm afraid.

Works fine in Mozilla but not in Safari and IE for Mac.
This time though it doesn't even reach the google page.

The previous attempts all called up google but didn't search the keyword.
They all only managed

http://www.google.com/search?q=

in the address bar.

Your new answer - hard to say what's going on exactly in Safari and IE for Mac - looks like the page just refreshes itself without sending any requests.

Thanks for the attempt - one last thing you could try for me if you have the facilty - post the code onto a dummy site and then i'll know if there's something up with my dreamweaver/mac. It's the only thing left I can think of.




http://members.aol.com/grassblad/getNpost.html

I also posted it in the html question -- perhaps someone else can check

Vinny

Well - change my name to macnuisance!!!

It works on your link!

presumably then so would the other solutions if i called them up from a www link

Nightmare Weaver more like - not to mention sleep depriver!

well - at least we have a solve - a range of solves in fact!

Apologies all round.

I'll try and see what my DW's upto tomorrow now.

Thanks all - (where's the keystrokes for embarressed face?)

   :(

[shuffle,shuffle]red[/shuffle \]  

  :D

Vinny
try using location.href and change the input type="submit" to input type="button"


<input type="button" name="myBtn" value="Search" onClick=" location.href = 'http://google.com/search?q='+ document.myform.search.value;">


I wrote  a search script a while back for someone here on EE, i do not have time right now to search for it or rewrite it, but if you want to look in my profile you will find it.

you might be interested in this thread - the q.s been answered but it's more or less a mirror of this one.

https://www.experts-exchange.com/questions/20777559/enable-google-get-form-within-post-action.html#9623050

is 200 points for slam and 100 points for vinny ok. [vinny - i gave you all the point s in the browser issue q.]

fine by me :-)
btw macuser:

  You do realize you will need to parse the user's search string, right?
  As of the last version I saw, I doubt if anyone had tested for a value with "two words"

Vinny
Hey Vinny,

It seems to work ok with more than one word.

Couldn't get the apple search off the ground in the end though :( The site allocates a new url when you visit that times out on the users machine if they don't search for a some time.

There's bound to be a way round this - like lifting url addresses out of address bars and refresh cycles and stuff!
But - i'm giving it a rest for a day or two.

Might be a bit much for an ExEx q.

 >btw ??? - that's a new one on me

macuser
btw --> by the way.

how are you differentiating between a search for  "Grassblade Javascript"  and  "Javascript has no Grassblade" ?

Vinny
...just been down the shops...

hmmm - i'm not sure what you mean by

>how are you differentiating....

but if i put those 2 searches through the google as a test they bring up different search results - so it recognises the different inputs if that's what you mean.
- similarly with teoma and lycos.

macuser