0

I am using Jquery Token-Input for autosearch field. I need to send PropertyToSearch field value dynamically.

HTML:

   <input checked="checked" name="suggest" type="radio" />Month
   <input name="suggest" type="radio" />Day</label>

As in the above html fields.

When i select Month, the list should be listed as Months and When i select Day, the list should be listed as week days.

Now i am passing propertyToSearch in default like below,

SCRIPT:

         $("#demo").tokenInput(../Management/getDaysAndMonths,
            {
                propertyToSearch: "Month",
                tokenLimit: 1
            });

How i need to set propertyToSearch field value dynamically. so that it can switch the listed values based on the selected radio button field.

please clarify me through suggestions.

thanks in Advance.

Community
  • 1
  • 1
logarajaks
  • 37
  • 1
  • 8

2 Answers2

0

use jquery selecot rto select the value...

$('input[name="suggest"]').val()
  -^^^^^^^^^^^^^^^^^^^^^^--selects input with name=suggest and .val() selects the selected radio value.

try this

HTML

<input checked="checked" name="suggest" type="radio" value="Month"/>Month
<input name="suggest" type="radio" value="Day"/>Day</label>

JQUERY

 $("#demo").tokenInput(../Management/getDaysAndMonths,
  {
     propertyToSearch:$('input[name="suggest"]').val(),
     tokenLimit: 1
  });
bipen
  • 36,319
  • 9
  • 49
  • 62
  • No.. Its not working properly. when we choose another radio button, the propertyToSearch value is not changing.It remains the first value which is in checked – logarajaks Feb 08 '13 at 09:28
0

I got a solution.

Instead of changing the propertyToSearch. I simply changed the code behind to list the values based on the input provided.

So, if month is selected. I pass a parameter "searchProperty" in url as month and if day has been selected I pass a parameter as day based on the searchProperty value. I list the values and pass it on the dropdown list.

     $("#demo").tokenInput("../Management/getDaysAndMonths?searchProperty="+$('input[name="suggest"]').val(),
       {
           //code
       });
Jez
  • 305
  • 2
  • 12
logarajaks
  • 37
  • 1
  • 8