[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

A Jquery Change

Posted on 2014-01-17
1
Medium Priority
?
293 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 59

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Hi all! Recently there was EE question and the person wanted to have a multi-column textbox <div> selection, so as a first step to answer I provided a link but that was not complete with JavaScript selection, but had a good style sheet. So as a ques…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

649 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