Reputation: 51
I am querying database to populate an input field and i am getting a long string returned from database so i want a single value from that string and other values to populate other input fields on selection, but unable to do so any help ?
Upvotes: 0
Views: 151
Reputation: 15860
If you're getting a string from database, then try to breaking it into substrings at the server-side page. That way, you will have the short strings to be written in the responce.
If you want to write it using jQuery then use this
var name = "Afzaal Ahmad Zeeshan";
var words = name.substring(5); // this is basic js
This way you will get substrings of the long string, and then write it to the div elements.
Then you can add them to hidden elements, and on click
you can show them using jQuery as
$('selector').click(function () {
$('other_selector').show(); // show the other element
}
This way, you'll get the divs being shown which are substrings of a long string.
Upvotes: 1