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 8024565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:54:09+00:00 2026-06-04T22:54:09+00:00

My popup.html: <!doctype html> <html> <head> <form name=orderform> First name: <input type=text name=firstname /><br

  • 0

My popup.html:

<!doctype html>
<html>
  <head>
      <form name="orderform">
First name: <input type="text" name="firstname" /><br />
Last name: <input type="text" name="lastname" />
<INPUT TYPE="button" NAME="button1" Value="Read" onClick="readText(this.form)">

</form> 
<!-- JavaScript and HTML must be in separate files for security. -->
    <script src="popup.js"></script>
  </head>
  <body>
  </body>
</html>

popup.js

console.log("In");
function readText (form) 
{
    TestVar =form.firstname.value;
    console.log(TestVar);
    chrome.tabs.create({"url":"http://www.google.co.in","selected":true}, function(tab){
       });
}

Unfortunately the above code does not print the value of a first name. Could someone please tell me what i am doing 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-04T22:54:11+00:00Added an answer on June 4, 2026 at 10:54 pm
    1. Your form is in the <head> section; move it in the body
    2. don’t use form.field, use the DOM id property in conjunction with document.getElementById().
    3. Use var to define local variables; like this:

      First name: <input type="text" id="firstname" /><!-- note the use of id=... -->
      <script type="text/javascript"> 
          var TestVar = document.getElementById('firstname').value;
      </script>
      
    4. use alert() for strings and numbers

    Here’s the full code:

    popup.html

    <html>
    <head>
    <script src="popup.js"></script>
    </head>
    <body>
    <form name="orderform">
        First name:
        <input type="text" name="firstname" id="firstname" />
        <br />
        Last name:
        <input type="text" name="lastname" id="lastname" />
        <input type="button" name="button1" value="Read" onclick="readText()">
    </form>
    </body>
    </html>
    

    popup.js

    function readText(){
        var TestVar = document.getElementById('firstname').value;
        console.log(TestVar); alert(TestVar);
        chrome.tabs.create({"url":"http://www.google.co.in","selected":true}, function(tab){  });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<!DOCTYPE html> <html> <head> <meta charset=utf-8 /> <title>Remote Control</title> </head> <link rel=stylesheet href=/../.. type=text/css
Given the following markup <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML Strict//EN><META http-equiv=Content-Type content=text/html; charset=utf-8> <HTML
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <link type=text/css href=Styles/Site.css rel=Stylesheet ></link >
Here's the literal HTML markup I have: <!DOCTYPE html> <html> <head> <title>Register</title> <link href=/Content/Site.css
I have following sample code: <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.1//EN http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd> <html> <head>
I copy the following from source of http://jquerymobile.com/demos/1.0/docs/pages/multipage-template.html <!DOCTYPE html> <html> <head> <meta charset=utf-8>
When a user puts in some text into my form and clicks the button,
popup.html is popped up by script from parent.html: window.open('popup.html', '', 'width=520, height=300,left=500,top=0'); Is it
I am using Jquery form plugin. Popup is displayed with image uploading form. Image
I am trying to popup an alert when the user clicks the 'like' button

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.