469,343 Members | 5,620 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,343 developers. It's quick & easy.

document.getElementById("starttimeScheduler") returns null

Hi, I am working on a webapplication,( with Ajax & JSF) where I want to retrieve the value present in a
Expand|Select|Wrap|Line Numbers
  1. <t:inputText id="starttimeScheduler"  value="#{scheduledJobCreateEdit.startTimeDate}" style="width:165px; margin-left: 25px;" forceId="true" tabindex="112">  
by using
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("starttimeScheduler") 
in my javascript function. but this is always returning null. The <t:inputText > is present with in a <t:div>. Can you please let me know , how can I get the <t:inputText > value . I have the issue with both FF and IE 7.
Mar 28 '08 #1
3 2120
malav123
217 100+
Hi,
pass the form and use it in java script, and if you are using master page then use the prefix of content place hoder and form your problem will be solved...
Mar 28 '08 #2
Hi,
pass the form and use it in java script, and if you are using master page then use the prefix of content place hoder and form your problem will be solved...
I didnt understand , when you mentioned "pass the form".
THe code I have is :
Expand|Select|Wrap|Line Numbers
  1. function checkScheduledDate()
  2. {
  3.  var scheduledTime = document.getElementById("starttimeScheduler"); 
  4.  if(scheduledTime == null)    
  5.  {
  6.    return false;
  7.  }
  8. }
  9.  
  10. <h:form>
  11. ...
  12. <t:div id="contents_starttime_div" styleClass="contents" style="border:none;">
  13. <t:inputText id="starttimeScheduler"  value="#{scheduledJobCreateEdit.startTimeDate}" style="width:165px; margin-left: 25px;" forceId="true" tabindex="112">
  14. <f:convertDateTime pattern="#{cal['jsfcalendar.pattern']}" locale="#{facesContext.viewRoot.locale.language}"/>
  15. </t:inputText>
.....

Now in my javascript function, I want to retrieve the value present in the input text at the time of form submission. So, I am calling the javascript function on submit, but the function always returns null on document.getElementById().
Please help me out here.
Mar 28 '08 #3
malav123
217 100+
Hi,
you just call the function from submit button like,
Expand|Select|Wrap|Line Numbers
  1.  Btn.Attributes.Add("onClick", "return yourfunction(this.form)")
and in your javascript use simply,
Expand|Select|Wrap|Line Numbers
  1. yourfunction(f)
  2. {
  3.          if(f.starttimeScheduler=="")
  4.                            alert("message");
  5. }
  6.  
now it will work fine for u.....
Mar 31 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Rene van Hoek | last post: by
1 post views Thread by Suresh | last post: by
2 posts views Thread by Jeff Adams | last post: by
1 post views Thread by js | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.