Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8717259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:15:51+00:00 2026-06-13T06:15:51+00:00

<script type=text/javascript> window.onload = init; function init() { //wait for load and watch for

  • 0
<script type="text/javascript">
window.onload = init;

function init() { //wait for load and watch for click
    var button = document.getElementById("searchbutton");
    button.onclick = handleButtonClick;
}

function handleButtonClick(e) { //get user input and go to a new url
    var textinput = document.getElementById("searchinput");
    var searchterm = textinput.value;
    window.location.assign("http://google.com/example/" + searchterm)
}
</script>

<form>
    <input type="text" name="search" id="searchinput">  
</form>
<input type="submit" value="Ara" id="searchbutton">

In this code block, it gets user input and go to a new url with user input.

if I move last line into form element it doesn’t working.
But I’m using id to find elements.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T06:15:52+00:00Added an answer on June 13, 2026 at 6:15 am

    Instead of

    <input type="submit" value="Ara" id="searchbutton">
    

    use this (MDN docu)

    <button type="button" id="searchbutton">Ara</button>
    

    Your button works as a form submit button, so instead of just executing your JavaScript, it also tries to submit the form, which points back to the script itself. By using <button type="button"> you define a mere button without any submitting functionality.

    Besides: If you don’t need the surrounding <form> element, why not drop it out of the code?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a PHP code: if($billing_total>$limit_to_send){ echo '<script type=text/javascript> window.onload = function() { alert(Sorry,
Here's my code: <script type=text/javascript> (function() { window.PinIt = window.PinIt || { loaded:false };
#!/usr/bin/perl print Content-type: text/html \n\n; print qq(<html> <head> <script type=text/javascript src=/jquery.js></script> <script> jQuery(document).ready(function(){ jQuery(#form_lang).submit(function(e){
This my javascript :- <script type =text/javascript> $(function() { $(#tabs).tabs({ cache: true ,fx: {
why aren't the cookies saved when i run the following script: window.onload=init; function init()
Here is fragments of my HAML view: %script{:type => text/javascript, :src => assets/application.js} :javascript
I have this code <html> <head> <script src=jquery-1.7.2.min.js type=text/javascript></script> <script src=jquery-ui-1.8.20.custom.min.js type=text/javascript></script> <script type
I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
Something really weird is happening, it works when I document.write() outside the window.onload =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.