?
Solved

A Jquery Change

Posted on 2014-01-17
1
Medium Priority
?
285 Views
Last Modified: 2014-01-18
i had a code which needs little modification,

working fine, but the only change required is to uncheckbox the selected checkbox if the value of the first textbox is changed and select the checkbox whose value is entered then

here is code for that

jquery UI and jquery 1.9.2 is already included

$(function () {
    var cbv;
    var detect = ["AcC", "Fridge", "Washing", "Almirah"];

    $("#inputfields").autocomplete({
        source: detect,
        select: function (event, ui) {
            var txt = (ui.item.value);
            $("#inputfields").val(txt);
            var inputdetect = $("#inputfields").val(txt);
            cbv = inputdetect.val();
            $("#" + cbv + "").attr("checked", true);

        },
        change: function () {
            $("#" + cbv + "").attr("checked", false);


        }
    });
});

<section>
    <label for="inputfields">Choose:</label>
    <input id="inputfields" />
    <br>
    <input type="checkbox" id="AcC">
    <label>AcC</label>
    <br>
    <input type="checkbox" id="Fridge">
    <label>Fridge</label>
    <br>
    <input type="checkbox" id="Washing">
    <label>Washing</label>
    <br>
    <input type="checkbox" id="Almirah">
    <label>Almirah</label>
</section>

Open in new window

0
Comment
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 58

Accepted Solution

by:
Julian Hansen earned 2000 total points
ID: 39790365
Just add this line
$(function() {
    var cbv;
    var detect = ["AcC", "Fridge", "Washing", "Almirah"];

    $("#inputfields").autocomplete({
        source: detect,
        select: function (event, ui) {
            var txt = (ui.item.value);
            $("#inputfields").val(txt);
            var inputdetect = $("#inputfields").val(txt);
            cbv = inputdetect.val();
            /*** ADD THIS ***/
            $('input:checked').attr('checked', false);
            $("#" + cbv + "").attr("checked", true);

        },
        change: function () {
            $("#" + cbv + "").attr("checked", false);


        }
    });
});
</script>

Open in new window

0

Featured Post

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question