document.getElementById("starttimeScheduler") returns null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • karprix
    New Member
    • Mar 2008
    • 2

    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
    Code:
    <t:inputText id="starttimeScheduler"  value="#{scheduledJobCreateEdit.startTimeDate}" style="width:165px; margin-left: 25px;" forceId="true" tabindex="112">
    by using
    Code:
    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.
    Last edited by gits; Mar 31 '08, 09:27 AM. Reason: added code tags
  • malav123
    New Member
    • Feb 2008
    • 217

    #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...

    Comment

    • karprix
      New Member
      • Mar 2008
      • 2

      #3
      Originally posted by malav123
      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 :
      [CODE=java]function checkScheduledD ate()
      {
      var scheduledTime = document.getEle mentById("start timeScheduler") ;
      if(scheduledTim e == null)
      {
      return false;
      }
      }

      <h:form>
      ...
      <t:div id="contents_st arttime_div" styleClass="con tents" style="border:n one;">
      <t:inputText id="starttimeSc heduler" value="#{schedu ledJobCreateEdi t.startTimeDate }" style="width:16 5px; margin-left: 25px;" forceId="true" tabindex="112">
      <f:convertDateT ime pattern="#{cal['jsfcalendar.pa ttern']}" locale="#{faces Context.viewRoo t.locale.langua ge}"/>
      </t:inputText>[/CODE]
      .....

      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.getEle mentById().
      Please help me out here.
      Last edited by gits; Mar 31 '08, 08:00 AM. Reason: added code tags

      Comment

      • malav123
        New Member
        • Feb 2008
        • 217

        #4
        Hi,
        you just call the function from submit button like,
        [CODE=javascript] Btn.Attributes. Add("onClick", "return yourfunction(th is.form)")[/code]

        and in your javascript use simply,
        [CODE=javascript]yourfunction(f)
        {
        if(f.starttimeS cheduler=="")
        alert("message" );
        }
        [/CODE]
        now it will work fine for u.....
        Last edited by gits; Mar 31 '08, 08:01 AM. Reason: remember to use CODE TAGS!!!

        Comment

        Working...