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

  • SEARCH
  • Home
  • 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 8648945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T13:26:11+00:00 2026-06-12T13:26:11+00:00

I am using a three part code below: First part of the code: Basically

  • 0

I am using a three part code below:

First part of the code: Basically a javascript function changeSearchEngine will be triggered when user select Google.

<p id="searchbox">This paragraph will change once javascript is triggered</p>
<form align=right>
<select name="searchengine" onchange="changeSearchEngine(this.form)">
<option value="google">Google</option>
</select>
</form>

This is my changeSearchEngine function in javascript.

function changeSearchEngine(form)
{
    var searchEngine=form.searchengine.value;
    if (searchEngine=="google")
    {
    var url_google='<form method="get" action="http://www.google.com/search" onsubmit="submitGoogle(this.form)" target="_blank"><input type="text" name="q" size="31" maxlength="255" value="" /><input type="submit" value="Google Search"/></form>';
    document.getElementById("searchbox").innerHTML=url_google;
    }
}

At this point of time, all is working well. When I select Google, the searchbox for google appears. I can search and everything.

Notice there is a onsubmit=”submitGoogle(this.form)” right? I need to save what the user search terms into SQL table. So I have this javascript function below to capture what user have type:

function submitGoogle(form)
{
    alert("Inside submitGoogle function");
        var searchterm=form.q.value;
    alert(searchterm); //to test. this part didnt capture the value.
}

I managed to invoke the submitGoogle function BUT however I can’t retrieve the value of q despite using searchterm=form.q.value. What did I do wrong here?

  • 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-12T13:26:13+00:00Added an answer on June 12, 2026 at 1:26 pm

    In your onsubmit handler, you are passing this.form. But, this already refers to the form since it is the form itself that triggers the submit event. Form fields have a form property, but the form itself does not have a form property. So, just change your handler to pass this instead of this.form.

    http://jsfiddle.net/fmqNj/

    onsubmit="submitGoogle(this)"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the code below to put together my UITableView. The Cell height
I have a code setup something like below, the image is part of a
Are there any open source projects or part of codes using which its possible
We are using GUICE framework as part of service layer. Now there is a
We are using a third part library to render 3d. In this library there
I am using three tables and I am trying to calculate discounted price by
I have the following animation set up using Three.js: http://frontier.lincoln.ac.uk/3d/development/Stage2/characters/man2.html Please ignore the ropey
I'm attempting to expose a single API call using three different authentication mechanisms: django's
For a couple of years, I've been using the three-tier architecture (Presentation, Logic and
I have three textareas using tinymce as text area. They all work in chrome

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.