0

I am having some anchor tags in the page and I have to set them all a value in query string and then trying to send it in controller can this be possible.Actually I have a hidden field on the page and that hidden field is set to a value when somebody selects a user from auto complete of jquery. Now my Question is that I am able to set hidden field a value but how can I assign value of hidden field to query string in an anchor tag. Please help me. I am trying in this way.

<div id="page">
   <div class="note-row2">
                <div class="form-left">
                    <input type="text" id="txt_Autocomplete" />
                    <input type="hidden" id="hdnPkClientId" />
                </div>
                <div class="form-right">
                </div>

<div class="right-row">
                <h3><a href="/GoToPage/Index?Client_ID="+"'$('#hdnPkClientId').val()'" >My Page</a></h3>
                   </div>
            </div>
</div>

Here I am setting the value in hidden field
<script>
  $("#txt_Autocomplete").autocomplete({
            source: function (request, response) {
                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: "/ClientHome/SearchClientDetail",
                    data: "{'searchtext':'" + document.getElementById('txt_Autocomplete').value + "'}",
                    dataType: "json",
                    success: function (data) {
                        response($.map(data.Data, function (item) {

                            return {

                                label: item.Name,
                                value: item.id,
                                data: item
                            };
                        }));
                    },
                    error: function (xhr)
                    { }
                });
            },
            select: function (event, ui) {
                var detailArr = ui.item.label.split(',');
                $("#txt_Autocomplete").val(detailArr[0]);
                $("#hdnPkClientId").val(ui.item.data.Id);

</script>

I

1 Answer 1

2

in your html:

<a id="YOUR_A" href="/GoToPage/Index?Client_ID=" >My Page</a>

in your js:

select: function (event, ui) {
    var detailArr = ui.item.label.split(',');
    $("#txt_Autocomplete").val(detailArr[0]);
    $("#hdnPkClientId").val(ui.item.data.Id);
    $("#YOUR_A").attr("href", "/GoToPage/Index?Client_ID="+ui.item.data.Id);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.