Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
when i click span values ,it passes text box using javascript
WHEN i click any span,TO show those all values in one modal popup.But in that modal popup particular clicked span value to change text box value.how is it possible




HTML TAG;

XML
<span class='txtToInput'>0.5</span>
<span class='txtToInput'>0.8</span>
<span class='txtToInput'>0.8</span>
<span class='txtToInput'>0.8</span>
<span class='txtToInput'>0.8</span>



javascript


XML
$(function () {
$('.txtToInput').live('click', function () {
    var input = $('<input />', {'type': 'text','class': 'txtToInput', 'name': 'aname', 'value': $(this).html()});
    $(this).parent().append(input);
    $(this).remove();
    input.focus();
});

$('.txtToInput').live('blur', function () {
    var span = $('<span />', {'class': 'txtToInput'});
    $(this).parent().append($(span).html($(this).val()));
    $(this).remove();
});
});
Posted
Updated 11-Aug-15 19:01pm
v3
Comments
Sergey Alexandrovich Kryukov 12-Aug-15 1:08am    
Not clear what you want to achieve. Better don't use deprecated .live(). Please see the documentation on this function for the explanation.
—SA
Member 10918596 12-Aug-15 1:28am    
i need to show modal popup
Member 10918596 12-Aug-15 1:30am    
every time i click span values it changes textbox values in modal dialog
Sergey Alexandrovich Kryukov 12-Aug-15 10:15am    
It is not shown in your code sample.
—SA
Member 10918596 12-Aug-15 1:28am    
i have updated my code

textbox = false;

$(document).on('click', '.updaterate', function () {
if (!textbox) {
alert('1111');
var input = $('<input />', { 'type': 'text', 'class': 'updaterate', 'name': 'aname', 'value': $(this).html() });
$(this).parent().append(input);
$(this).remove();
input.focus();
textbox = true;
}
});


$(document).on('blur', '.updaterate', function () {
if (textbox) {
alert('2222222');
var span = $('<span />', { 'class': 'updaterate' });
$(this).parent().append($(span).html($(this).val()));
$(this).remove();
textbox = false;
}
});

1 solution

Not sure if this is what you want to achieve
Solution[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900