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

  • SEARCH
  • Home
  • 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 8172135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:41:24+00:00 2026-06-06T21:41:24+00:00

I have the following Jquery that returns values from a dialog Box and fills

  • 0

I have the following Jquery that returns values from a dialog Box and fills in the values in the main page :

function AutoCompleteTopayer(pName, addLine, pCity, pState, pZip, pPhone) {
        $(".PayerName").html(pName);
        $("#txtPayerAddress").val(addLine);
        $("#txtPayerCity").val(pCity);
        $("#txtPayerState").val(pState);
        $("#txtPayerZip").val(pZip);
        $("#txtPayerPhone").val(pPhone);
        var csz = pCity + ", " + pState + ", " + pZip;
        $("#txtCStateZip").val(csz);
        $("#SearchPayDlg").dialog("close");
    }

Code from my View :

    @Html.TextBoxFor(model => model.cityStateZip, new { @class = "fauxInput", id = "txtCStateZip" })
    @Html.HiddenFor(model => model.payerCityName, new { id = "txtPayerCity" })
    @Html.HiddenFor(model => model.payerStateCode, new { id = "txtPayerState" })
    @Html.HiddenFor(model => model.payerPostalZoneOrZipCode, new { id = "txtPayerZip" })

This gives the following output:

Output1


When I replace the TextBoxFor with DisplayFor … The values are not shown. I’ve found one article that somehow adresses my issue here ,so I’ve comeup with this code :

<span class="txtPayerName">
     @Html.DisplayFor(model => model.payerName, new { @class = "fauxInput" })
 </span>

and in the JQuery method :

$(".txtPayerName").html(pName);

,but that doesnt work either.Any solutions ?


Later Edit: Sorry , i found out it was all about a typo… the last one actually works .. I’ve edited and gonna let it here so others may benefit from it.

The above code works with the sole remark that the displayFor’s class will not work( thanks Darin Dimitrov), so this should work:

 <span class="txtPayerName fauxInput">
         @Html.DisplayFor(model => model.payerName)
     </span> 
  • 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-06-06T21:41:26+00:00Added an answer on June 6, 2026 at 9:41 pm

    The second argument of the DisplayFor helper doesn’t do at all what you think it does (apply CSS class). It allows you to pass additional ViewData to the display template.

    So you could apply the CSS to the containing element

    <span class="txtPayerName fauxInput">
        @Html.DisplayFor(model => model.payerName)
    </span>
    

    and then adapt your selector:

    $('.fauxInput').html(pName);
    

    Your code also works because in your selector you used $(".txtPayerName") but it is important to point out that there won’t be any fauxInput if you use this approach.

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

Sidebar

Related Questions

I have the following jquery function that submits to an iframe. The message sent
I have the following php script that is called by jquery ajax function report_range($time,
I have the following jquery Autocomplete form that pulls data in from a local
I have a webservice function that returns something like the following: New Orleans, Louisiana
I have the following JavaScript/jQuery code that starts the listener that highlights the DOM
I have the following block of jQuery code that I'm using to copy some
I have the following jQuery calls chain: $(someSelector).nextUntil(.specialClass).addClass(classBasedSomeSelectorObject) I need to addClass that's value
I have the following scenario jQuery('#content').fadeOut('slow',function(){ jQuery('#content').load(detail.php?product=+imgID+&category=+cat); jQuery('#content').fadeIn('fast'); }); My problem however is that
As per title. I have a piece of jQuery that looks like the following
I have a Jquery code that is following: var selectedQuestions = $(#SelectedQuestions); var selectedCustomQuestions

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.