Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

document.getElementById coming as undefined/null

 
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
<htm:table id="htmtable1" border="0" width="100%" >

<htm:tr>

<htm:td width="60%" styleClass="lableStyleLeft">

<h:selectOneRadio id="rptType" layout="lineDirection" value="Admin_Agent_Report" styleClass="pr_boldInner" onclick="loginauditReportChk();">

<f:selectItem id ="rpttype1" itemLabel="Admin/Agent Report" itemValue="Admin_Agent_Report" />

<f:selectItem id ="rpttype2" itemLabel="Login Audit Report" itemValue="Login_Audit_Report" />

</h:selectOneRadio>

</htm:td>

<htm:td width="40%">

<h:outputText/>

</htm:td>

</htm:tr>

</htm:table>

I have the javascript function below



function loginauditReportChk(){

alert('from inside loginauditReportChk js');
var var1=document.getElementById("adminPanel:adminForm:rptType");
alert(var1 + " - " + var1.value);

}

The last alert above doesnt provide me the desired results ie. the element name and the value. It tells me that var1 is a HTMLTableObject and var1.value comes as undefined or null. Please assist on the below questinos :
1 . I read smwhere in this forum that the document is not yet created hence the issue...could someone please elaborate this point.
2. Am using tomcat to run the applciation. Am I missing any jars, if so what are they.

 
Greenhorn
Posts: 5
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Try accessing your element in this way.

document.getElementById("rptType");
 
jose chiramal
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Here I have the button named rptType inside the form named adminForm which is inside the panel named adminPanel

document.getElementById("adminPanel:adminForm:rptType");
 
jose chiramal
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Also am using safari as my browser. So please let me know if that could be the issue and the fix to overcome the same. Thanks.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
when you post code, use code tags!

View the page source, what is the id. Looking at serverside code is useless.

Eric
 
Sheriff
Posts: 67645
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I have closed this topic. When posting to this forum, post the rendered HTML not the JSF source.
 
    Bookmark Topic Watch Topic
  • New Topic