Any Javascript coder can help? |
[eluser]srpurdy[/eluser]
Below is a script that is creating 2 boxes when you push the add button, My Problem is when I add 2 new boxes anything entered into the first 2 gets ereasd. I don't really know javascript that well, at all really lol. Wondering if anyone knows how I can prevent that data from being erased? Another issue I'm having is below but not as important. Code: [removed]<!-- Code: <div id='textBoxes'> Ok the second issue. Is this is an array of data being place into two fields. I have an edit feature so you can go back and fix a typo whatever. When I go there I am inputing the array into they're own text boxes. Then problem I have now is Say I want to remove one section of the array. I cannot remove anything, Even though those boxes exist. If I add a new one I beleive it is starting the array from the begining. Isntead of starting at the next one. I'm sure this is both a php problem as well as javascript problem Below is the code, I took out the Add Remove buttons since they were useless. Code: <? Any help would be appricated. I know I'm breaking all the MVC rules but im still learning lol. Shawn
[eluser]lifo101[/eluser]
To answer your first question, The reason the text boxes disappear is because of the way you're inserting the new boxes by using $.html() + 'more html'. That will cause the browser to erase the content that was there and recreate it with the text you're passing in. Lookup the $.after() function on jquery's site to append your new textboxes after the last one found. for example: Code: var counter = 2;
[eluser]srpurdy[/eluser]
Cool thanks man, That worked I fixed part of my second issue by using the code below Code: <?php for($i = 0; $i < count($corners); $i++) : ?> I added Code: <?=$i?> And added the textboxs div below, and add, remove buttons. I can add a new array values and keep them in order. However I can only remove new ones I add at that point not existing ones. Anyone got a solution for removing existing boxes ? |
Welcome Guest, Not a member yet? Register Sign In |