New to javascript please help me create a link after we click on submit button
What is happening is when we click on submit button, it directly does the action on query to google
But instead need this to create a link
I mean when we hit search the javascript has to create a link and not query google
When we click on the link it should query google and not before that

Any solution please advice

<html>
<title> </title>
<head>
<script type="text/javascript">

var refine="resume"
var elim="-job"
function google(hit){
hit.q.value= hit.qfront.value+" "+refine+" "+elim

}

</script>

</head>
<body>
<form action="http://www.google.com/search" method="get" onSubmit="google(this)"/>
<p>PureSearch<br />
<input name="q" type="hidden" />
<input name="qfront" type="text" style="width: 180px" /> <input type="submit" value="Search" /></p>
</form>
</body>
</html>

Recommended Answers

Your javascript is requesting a value that isn't there.

Why do you need to do this? What benefit would this be? It would surely take more time to type a query, click a button, generate text to create a link then click it to finally get to google!

Jump to Post

I am most probably missing something here, but the url seems to be working quite well, whatever i typed in the search box gets sent to the google search.

I dont see a problem.

Jump to Post

All 6 Replies

Your javascript is requesting a value that isn't there.

Why do you need to do this? What benefit would this be? It would surely take more time to type a query, click a button, generate text to create a link then click it to finally get to google!

Actually there are multiple variable going to be there say like 50
When i click on search
all 50 links should hold that query

<html>
<title> </title>
<head>
<script type="text/javascript">

var refine="resume"
var elim="-job"
function google(hit){
hit.q.value= hit.qfront.value+" "+refine+" "+elim

}

</script>

</head>
<body>
<form action="http://www.google.com/search" method="get" onSubmit="google(this)"/>
<p>PureSearch<br />
<input name="q" type="hidden" />
<input name="qfront" type="text" style="width: 180px" /> <input type="submit" value="Search" /></p>
</form>
</body>
</html>

I am most probably missing something here, but the url seems to be working quite well, whatever i typed in the search box gets sent to the google search.

I dont see a problem.

New to javascript please help me create a link after we click on submit button
What is happening is when we click on submit button, it directly does the action on query to google
But instead need this to create a link
I mean when we hit search the javascript has to create a link and not query google
When we click on the link it should query google and not before that

Any solution please advice

<html>
<title> </title>
<head>
<script type="text/javascript">

var refine="resume"
var elim="-job"
function google(hit){
hit.q.value= hit.qfront.value+" "+refine+" "+elim

}

</script>

</head>
<body>
<form action="http://www.google.com/search" method="get" onSubmit="google(this)"/>
<p>PureSearch<br />
<input name="q" type="hidden" />
<input name="qfront" type="text" style="width: 180px" /> <input type="submit" value="Search" /></p>
</form>
</body>
</html>

what are the addresses of links to be created?
where does the script get domain / location information?

I don't see any example of the main 'ingredient' for to create a link -you will need some address to pass to it.

And you will also need some visual elements to be clicked onto, so either create some text nodes or have them already written in your html prior to thinking of making any conversion.

Actually there are multiple variable going to be there say like 50
When i click on search
all 50 links should hold that query

<html>
<title> </title>
<head>
<script type="text/javascript">

var refine="resume"
var elim="-job"
function google(hit){
hit.q.value= hit.qfront.value+" "+refine+" "+elim

}

</script>

</head>
<body>
<form action="http://www.google.com/search" method="get" onSubmit="google(this)"/>
<p>PureSearch<br />
<input name="q" type="hidden" />
<input name="qfront" type="text" style="width: 180px" /> <input type="submit" value="Search" /></p>
</form>
</body>
</html>

The Magic Key-Word for converting some element into a valid clickable Link, is:

object.link(string)

where, [object] is the (existing or dynamically the created) html element you want to convert into a Link.
And the [string] is the reference to a string variable containing the address or the string itself, ie:
"http://www.google.com/search?hl=en&q=javascript+create+link&aq=o&oq=&aqi="

var link1 = "search google".link("http://www.google.com/search?hl=en&q=javascript+create+link&aq=o&oq=&aqi=")

Now - you pick your strategy!

p.s.:
you can test it directly by pasting this code:

javascript:document.write("search google".link("http://www.google.com/search?hl=en&q=javascript+create+link&aq=o&oq=&aqi="))

In your browser location bar and hit enter to meet the newly created link wit its query for "javascript create link"

will let you know when i integrate Will do it tommorow and will you know how it goes

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.