Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

I am working on a project in which I have two DIVs (DIV1, DIV2), both have no. of text boxes which are creating dynamically.
I have to hide one of the DIV. On another DIV click event I am showing these DIVs accordingly and enter some text in those textboxes of DIV1. When I hide this div1 and show the DIV2 and enter some text in some textboxes of the DIV2 and hide it. When I show the DIV1 the textboxes are empty. I want these textboxes to retain their values that I entered before I hide it. The same occurs with DIV2 as well.
All these operations are doing by jquery and I need help in jquery.

Can any body help me please.
Thanks in Advance.
Posted
Comments
thatraja 27-Dec-11 23:59pm    
Show the code
Sergey Alexandrovich Kryukov 28-Dec-11 0:13am    
That is strange. When you hide a DIV and show it again, everything in it should retain. What happened? Please show your code.
--SA
tanweer 28-Dec-11 0:15am    
Thanks for reply.
I am hiding these divs on another div's click event as

$(document).ready(function () {

$('#MainDiv').click(function () {
$('#DIV1').hide();
$('#DIV2').show();
});
});

1 solution

assuming div1 has a textbox1 and div2 has a textbox2 then

JavaScript
$(document).ready(function () {
  $('#MainDiv').click(function () {
 $('#DIV1').hide();
 $('#textbox2').value($('#textbox1').value());
 $('#DIV2').show();
});
});


regards
 
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