making button enabled based on div innerhtml set by ajax funtion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • divyaphilip
    New Member
    • Mar 2008
    • 5

    #1

    making button enabled based on div innerhtml set by ajax funtion

    Hi,
    I have a javascript function that uses ajax to set a div based on a query.
    The javascript function is invoked on a button click and uses ajax like this:
    [CODE=javascript]function validDate(node, roomid)
    {
    var allparams= 'timechk=' + params +'&starttime=' +params1 +'&endtime=' + params2 +'&roomid=' + params3 +'&ckres=' + params4
    var ajax = new Ajax.Updater(
    {success:ck_res },
    url,
    {method: 'get', parameters:allp arams, onFailure: reportError});
    }

    }
    [/CODE]ck_res is the div whose innerhtml should be set

    this is the ajax function that sets the div

    [CODE=cfm]<cfif NOT IsDefined("url. timechk")>
    <div >Please enter a valid date.</div><cfabort>
    </cfif>
    <cfquery datasource="#ap plication.datas ource#" name="datelooku p">
    SELECT ---------
    </cfquery>
    <cfif datelookup.reco rdcount>
    <div ><cfoutput>Th is date is booked.</cfoutput></div>

    <cfelse>
    <div >This date is free.</div>

    </cfif>
    [/CODE]I have a save button on my form.And i want it disabled until the div is set as "This date is free".How do I do that?
    Last edited by acoder; Mar 18 '08, 12:05 PM.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The Ajax Updater will have an onSuccess event. In that, call a function that checks the contents of the div for "This date is free". If found, set the Save button's disabled property to false.

    Comment

    • divyaphilip
      New Member
      • Mar 2008
      • 5

      #3
      Originally posted by acoder
      The Ajax Updater will have an onSuccess event. In that, call a function that checks the contents of the div for "This date is free". If found, set the Save button's disabled property to false.
      thanks again :) ............... .............

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        You're welcome :)

        Comment

        Working...