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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:22:54+00:00 2026-05-27T10:22:54+00:00

I am calling a function named ‘capital()’ but it is not working and ‘capita’

  • 0

I am calling a function named ‘capital()’ but it is not working and ‘capita’ is working.
is it a keyword in js or what is this ?

here is the code see it, test it

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HTML Select Element</title>
<script type="text/javascript">
function capita(){
alert('yes');
c = new Array("Islamabad", "Tehran", "Bejing", "New Delhi", "Kabul");

var i;
i = document.f1.country.selectedIndex;
document.f1.capital.value=c[i];
}
</script>
</head>
<body>
<h3>Countries and Capital</h3>
<form name="f1" method="post">
The capital of 
<select name="country" id="country" onChange="capita();">
<option selected>Pakistan
<option>Iran
<option>China
<option>India
<option>Afghanistan 
</select>
is <input type="text" name="capital" value="Islamabad"/> 
</form> 
</body>
</html>
  • 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-05-27T10:22:55+00:00Added an answer on May 27, 2026 at 10:22 am

    capital is a reference to your input element.

    <input type="text" name="capital" value="Islamabad"/>
    

    This is because when you use inline handlers, there are certain DOM elements that are inserted into the variable scope chain. Exactly which elements are inserted depends on the browser to some degree.

    If you change the onchange handler of your select element to this:

    <select name="country" id="country" onChange="alert(capital);"> 
    

    You’ll see that it alerts:

    "[object HTMLInputElement]"
    

    …or something similar.

    JSFIDDLE DEMO


    Here’s an updated example that changes your inline handler like this:

    <select name="country" id="country" onChange="alert('LOCAL: ' + capital + 
                                                 '\n\nGLOBAL: ' + window.capital);"> 
    

    So now it alerts capital and window.capital. If you test this in different browsers, you’ll probably get different results.

    JSFIDDLE DEMO

    Chrome shows:

    LOCAL: [object HTMLInputElement]

    GLOBAL: function capital() {}

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

Sidebar

Related Questions

Hi I have the following code in which I am calling a function named
I'm trying to return a value from (transport) to the calling function, but can't
I'm calling a function with call_user_func_array : call_user_func_array(array($this, 'myFunction'), array('param1', 'param2', 'param3')); Everything is
This code discussing named arguments in Clojure from The Joy of Clojure: (defn slope
Why calling a user defined function need the owner name when calling a stored
Does anyone know how to watch a variable in calling function. For example: C#:
I'm calling a function and adding a listener for when the function returns some
Suppose you are calling a function, where there's clearly a need to break down
I am calling a function in my controller from a button click .... I
Is there anyway to calling a function from another function .. little hard to

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.