Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C# MVC read value inside a div using jquery

I am developing an Application in Asp.Net Core MVC6.

I have a Razor page that render dynamically object.

Assuming I have creating dynamically this two Divs in my page

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

 <div id="A1">
         <input type="text" id="SearchSSN" />
        <input type="text" id="SearchLastName" />
    </div>
    <div id="A2">
         <input type="text" id="SearchSSN" />
        <input type="text" id="SearchLastName" />
    </div>
<a href="#" onclick="Search()" class="nav-link px-4 py-4" title="Show All"></a>

When I call Search() function in javascript, I want to read the value inside each Div

function Search() {
-- to read value from Object
var SSN: $("#SearchSSN").val(),
}

But I want to read the value inside each Div

Something like

$("#A1").("#SearchSSN").val()
$("#A2").("#SearchSSN").val()

How can I Do it?

Thanks

>Solution :

Modify your Search() Method like this

function Search() {
    var A1_SSN = $("#A1").find("#SearchSSN").val();
    var A1_LastName = $("#A1").find("#SearchLastName").val();

    var A2_SSN = $("#A2").find("#SearchSSN").val();
    var A2_LastName = $("#A2").find("#SearchLastName").val();

    // do something
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading