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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:23:48+00:00 2026-06-18T08:23:48+00:00

Following is my HTML code <div id=dl_address class=dl-row> <div class=dl-col1> <span id=dl_addressMarker class=dl-Marker>*</span>Address: </div>

  • 0

Following is my HTML code

<div id="dl_address" class="dl-row">
 <div class="dl-col1">
    <span id="dl_addressMarker" class="dl-Marker">*</span>Address:
 </div>
 <div class="dl-col2">
  <input  id="dl_addressMarker" name="p.streetAddress" maxlength="100" size="15"  
                            class="landing-qualpanel-input-standin" type="text" onClick="formOpt(id)" value="Home Address">
 </div>
</div>

And Following is my javascript code

<script language="javascript" type="text/javascript">
function formOpt(x){

    var y=document.getElementById(x).value;
    alert(y);
    }
</script>

I can’t understand why i am getting Undefined. Kindly Help.
Thanks in advance

  • 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-18T08:23:50+00:00Added an answer on June 18, 2026 at 8:23 am

    That’s because you have two elements with the same Id, which isn’t allowed in HTML and which makes it impossible for your function to get the input this way.

    Change the id of your input and you’ll be fine.

    You could simplify the code by passing the element and not the id :

    HTML :

    <input  id="dl_addressMarker2" name="p.streetAddress"
          maxlength="100" size="15"  
          class="landing-qualpanel-input-standin" type="text"
          onClick="formOpt(this)" value="Home Address">
    

    JavaScript :

    function formOpt(x){
       var y = x.value;
       alert(y);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following html code: <div class=tests> <input name=premise id=premise type=radio class=required value=0><span>0</span>
I have the following html code: <div class=Radios> <span class=radio> <input type=radio value=1> yes
I have the following html code : <div class=submit><input type=button name=getResult value=Get Comments class=sbutton
I have the following code: HTML <div id='foo'> <input type='checkbox' value='english' name='bar[english]' /> <input
I have the following HTML code: <div class=container> <span class=red></span> <span class=hot></span> </div> On
I have the following html code like this: <div class="question"> <input class="cross-reference-question-value-id" id="enr_rds_question_ids" name="enr_rds_surv_rdsap_xref[enr_rds_question_id]"
I have the following html code: <div class= modal id=indexModal> <span class=thing></span> <a href=#
I have the following html code with Jquery Sorting <div class=sortable style='width:700px; margin: 0
Suppose I have the following html: This a test of <code>some code</code>. <div class='highlight'>
I have the following CSS: html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td { background: transparent; border: 0; font-size: 100%; margin:

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.