javascript - jQuery DatePicker Update Options based on Radio Button Selection -


Whenever a different radio button is selected, I am trying to get a jquery date picker to update .

  & lt; Div style = "padding-down: 50px;" & Gt; & Lt; Label & gt; Location: & lt; / Labels & gt; & Lt; Input type = "radio" name = "locate" value = "internal" & gt; Internal & lt; Input type = "radio" name = "find out" value = "external" & gt; External & lt; / Div & gt; & Lt; Div & gt; & Lt; Label & gt; Due date: & lt; / Labels & gt; & Lt; Input type = "text" name = "dueDate" id = "fixed date" size = "25" placeholder = "please enter date" autocomplete = "off" readonly = "true" & gt; & Lt; / Div & gt;  

jQuery works but it does not update datePicker every time a new radio button is clicked.

  var locate = null; $ ("Input [name = 'locate']"). Click (function () {locate = this.value; if (locate == "internal") {$ ("#dueDate") .datepicker ({minDate: 'warning ("internal");} and {$ (" #dueDate "). Data picture ({minDate: -0, maxDate: '+ 6M'}); Alert (" External ");}});  

< Div class = "post-text" itemprop = "text">

You are not receiving the checked value of the radio button correctly if you change the if position as follows ($ "(" Input [name = 'locate']: checked "). Val () == 'internal') {$ (" #dueDate ") .Det Picker ({minDate: '-6M', Max: '+ 6 ('Minus');} and {$ ("#dueDate"). Datapikar ({minDate: -0, maxDate: '+ 6M'})}}

UPDATE 1 : Use Delete to delete the datepicker and redraw it as a radio button option change. Here is the complete code.

  $ ("input [name = 'locate']"). Click (function () {locate = this.value; Var dateField = $ ('#dueDate'); If ($ ("input [name = 'locate']: checked"). Val () == 'internal') {dateField.datepicker ('deleted'); DateField.datepicker ({minDate: '-6m', max.: '+ 6 m'}) Other} {dateField.datepicker ('deleted'); DateFieldDataIcker ({minutes: -0, max. DET: '+ 6 M'});}});  

When you select internal , you can go back for 6 months and when extralle is selected, it is currently Is the date


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -