Set lable to value of hdnfield

I have a hidden field that is populated when a user clicks on a jquery autocomplete form.

I need to pass this value so its stored in and displayed on the page...Im guessing a lable is appropriate as I only need to display the value.

I will use the value later to build an insert statement.

so I have some html for a lable
 <table id="new-row-template" style="display:none">
        <tbody>
            <tr>
                <td><label></label> 
                </td> 
                <td>

Open in new window


I have some html that gets the autocomplete

 <div class="col-md-2">
                @Html.TextBoxFor(x => x.SearchEntityNameOrId, new { @type = "text", @placeholder = "Search", @class = "caAutoComplete_EntityEntityNameSearch", @style = "width:100%!important;" })
            </div>

Open in new window



and here I stored the value in autocomplete to the hidden field

    $(".caAutoComplete_EntityEntityNameSearch").autocomplete(
        {
            source: "@Url.Content("~/Shared.mvc/EntityEntityNameSearchAuto")",
            minLength: 3,
            select: function (event, ui) {
                var inputlabel = ui.item.label;
                var inputvalue = ui.item.value;
                $("#hdnClientId").val(inputlabel);
                addNewRow();
             return false;
            }
        });

Open in new window

LVL 11
Robb HillSenior .Net DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
replace :
$("#hdnClientId").val(inputlabel);

Open in new window

by :
$("#hdnClientId").val(inputlabel);
$("#new-row-template label:eq(0)").text(inputlabel);

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
I need to clarify something.

In your autocomplete function you are calling addNewRow()
I also see your HTML template is hidden
 <table id="new-row-template" style="display:none">

Open in new window


So my question is - are you adding multiple items to a page?
If so I see a potential problem with this line
$("#hdnClientId").val(inputlabel);

Open in new window

Which is targeting a single ID

Can you explain your code a bit more so the above is put in context.
Robb HillSenior .Net DeveloperAuthor Commented:
only needs to account for the item when its clicked.
Julian HansenCommented:
I don't understand - can you respond to my earlier questions?
Robb HillSenior .Net DeveloperAuthor Commented:
the original post worked for me.   its just a dropdown...one click....stored the value....save....move on to next.


Thanks for both of your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.