Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6534055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:12:17+00:00 2026-05-25T10:12:17+00:00

In my form I’m adding a number of input elements in a For Loop,

  • 0

In my form I’m adding a number of input elements in a For Loop, as below.

 @For Each itm As LineItem In Model.LineItems
            Dim lnitm As LineItem = itm
    @<tr>

            <td>@lnitm.Name
            </td>
            <td>@Html.TextBoxFor(Function(model) model.LineItem(lnitm.ID).Value)
            </td>
            <td>@Html.TextBoxFor(Function(model) model.LineItem(lnitm.ID).Currency)
            </td>
        </tr>

        Next

I’d like to add some jQuery to the Currency textbox so I can get the autocomplete working.
In my other pages I’ve used a jQuery function such as:

$(function () {
$("#HomeCurrencyID").autocomplete({
        source: function (request, response) {
            $.ajax({
                url: "/autocomplete/Currencies", type: "POST", dataType: "json",
                data: { searchText: request.term, maxResults: 10 },
                success: function (data) {
                    response($.map(data, function (item) {
                        return { label: item.ID + " (" + item.Symbol + ") " + item.Description, value: item.ID , id: item.ID }
                    }))
                }
            })
        },
    });
});

This works fine where I know the ID of the Input Element / where I’m specifically adding the element into the HTML and not adding it via a loop.

How can I add the jQuery functionality above to all currency textbox’s created in the For Loop? Do I need to add Javascript at run time?

Resolution

Changed the Function declaration to a classname and added the class to the textbox as below;

$("#CurrencyClass") 

@Html.TextBoxFor(Function(model) model.LineItem(lnitm.ID).Currency, New With {Key .class = "CurrencyClass"})

Thanks for the prompt response!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:12:17+00:00Added an answer on May 25, 2026 at 10:12 am

    You’ll need to be able to select all of these textboxes to run the auto-complete script against, to do this you can add a class, then update the selector in your script.

    In the view: Give all of the textboxes a class using new {@class = "yourClass"} (or its VB equivalent) as the htmlAttributes parameter to the textbox helper (see http://msdn.microsoft.com/en-us/library/ee703535.aspx#Y200).

    In the script: Replace $("#HomeCurrencyID") with $(".yourClass"), it will run those functions to all of the matched elements, which will be the textboxes with yourClass.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Form contains two dropdown lists created using code below. Both dropdown list elements have
Form contains input elements and submit button. Pressing Submit button shows pdf file in
I have a form like this: <form name=mine> <input type=text name=one> <input type=text name=two>
form: <form id=defineForm method=POST action=api/test> <fieldset> <legend>Generale</legend> <input type=text name=id size=60 maxlength=60/> <input type=text
Form by example. $fullname = 'John Travolta'; <input type=text name=fullname /> <input name=same type=checkbox
Form: $headerValues=array(); $headerValues[1][2]=Test; ... .... echo <input type=\hidden\ name=\ArrayData\ value=\$headerValues\/>; echo <input type=\submit\ name=\submit\
Form the below string I would like to get the index of the starting
HTML: form input:radio 1 input:radio 2 input:radio 3 If one of these is clicked,
On form 1, I have a formtastic date_select field. = f.input :date_from, :discard_day =>
My form <form action=saveProfile.php method=post name=ProfileUpdate id=ProfileUpdate > <input name=Smeknamn id=Smeknamn type=text value=<?php echo

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.