[RESOLVED] Auto change field values after user changes something...?
Ok, so i have a form, and it loops to create a new "set" of data for each of the items in my database list.
Basically, I have this for each line:
- Title
- Duration
- Start Date
- Assigned User
- Completion Status
I need the start-date to get bumped by "X" amount of days if one of the items changes... so that every line following the one that was changed manually will just automatically update with "X" days later for the starting date.
So if title1box was the ID for task 1... and title2box was the ID for task 2, and so on... If you change task 4 to start 2 days later than before, I need tasks 5, 6, 7, 8, 9, etc to update to 2 days later but I need tasks 1, 2, and 3 to be left alone.
Oh! Also, I'd like for this to happen automatically while they're filling it out so that they can then edit other ones afterward with the right values in them. But I don't want it to save the changes until they click submit. I can handle that part on my own.
it's a good idea to show your (maybe simplified) code. if somebody decides to help you he must write "your page" with "your form" to test the script. if you need help respect people who help you )
use [code]YOUR CODE GOES HERE[/code] or burn in Hell
push your form fields onto an array, find out the index of the field that was changed, then loop through the fields after that index number, getting the existing value and adding whatever the changed amount was to each field value.
but Padonak is right... if you want something more specific, it would probably be wise to show some code at least...
Ok, my page loops through each "type of task" and displays one set of this for each one... Hope it helps.
Also, the "_1" is the part that increments per task, so the next one would have "_2" then "_3" and so on... for each task.
HTML Code:
<tr class="oddTD tableTopRow"><td rowspan="2"><input type="checkbox" name="done_1" value="complete" onClick="javascript:return confirm('Warning!\n\nThis change is permanant. If you mark this task complete\nyou will need to ask the system administrator to reset\nthis task if you made a mistake or want it to show again.\n\nAre you sure you want to mark this task as completed?')" /></td><td rowspan="2" class="leaderCol">Task Title</td><td class="datepicker"><input name="start_1" value=""></td><td><select name="person_1"><option style="color:rgb(204,204,204);font-style:italic;">No Person Assigned</option><option value="5">John Smith</option><option value="4" selected>Jane Smith</option></select></td><td rowspan="2"><textarea name="notes_1" rows="1"></textarea></td></tr><tr class="oddTD"><td class="datepicker"><input type="button" value="Select" onclick="displayDatePicker('Start0Date', this);"></td><td><select name="duration_1"><option value="1">Task takes 1 Day</option><option value="2">Task takes 2 Days</option><option value="3" selected>Task takes 3 Days</option><option value="4">Task takes 4 Days</option><option value="5">Task takes 5 Days</option><option value="6">Task takes 6 Days</option><option value="7">Task takes 7 Days</option></select></td></tr>
So if the start-date or the duration change for one task then all of the following tasks need up date with the same amount of days added or subtracted from what it was before.
<input type="hidden" name="lot" value="1804" /><tr class="oddTD tableTopRow"><td rowspan="2"><input type="checkbox" name="done_2" value="complete" onClick="javascript:return confirm('Warning!\n\nThis change is permanant. If you mark this task complete\nyou will need to ask the system administrator to reset\nthis task if you made a mistake or want it to show again.\n\nAre you sure you want to mark this task as completed?')" /></td><td rowspan="3" class="leaderCol">Backfill</td><td class="datepicker"><input name="start_2" value="04/16/2012" class="orOddEven"></td><td><select name="person_2"><option style="color:rgb(204,204,204);font-style:italic;">No Person Assigned</option><option value="6">John Smith</option><option value="5">Jane Doe</option><option value="4">Joe Schmoe</option></select></td><td rowspan="3"><textarea name="notes_2" rows="3"></textarea></td></tr><tr class="oddTD"><td class="datepicker"><input type="button" value="Select" onclick="chooseDate('Start0Date', this);"></td><td><select name="duration_2"><option value="1">Same Day</option><option value="2">Task takes 2 Days</option><option value="3">Task takes 3 Days</option><option value="4">Task takes 4 Days</option><option value="5">Task takes 5 Days</option><option value="6">Task takes 6 Days</option><option value="7">Task takes 7 Days</option></select></td></tr><tr class="oddTD"><td><input type="submit" value="-" class="incbutton"><input type="submit" value="+" class="incbutton"></td><td colspan="2">Last Updated (N/A)</td></tr>
I have a set like that generated for each task in the database's "list" of tasks...
I'm still having trouble figuring out how to make each additional task update to a later starting-date.
Also, I'd like the little "-" and "+" buttons to be the ones to affect that change.
Any help would, as always, be greatly appreciated.
Also, I don't need it to save the changes to the server until they're done and they can click submit... I just need it to auto-populate the date field when they click + or - and automatically update every task after it with the same amount added or subtracted.
What if they do each have a unique id? Would that make it easier too? Or more difficult?
I've got like 50+ tasks and the amount of tasks is dynamic, because the user can add/remove/change one on another page and the info is stored in the database.
Also, I still need to be able to call it with PHP after the form is submitted... I use "$_REQUEST['start23date']" or something like that... (where 23 is the automatically-generated id number of the whole task, which gets embedded in everything)
What if they do each have a unique id? Would that make it easier too? Or more difficult?
makes no difference to the code I posted
Originally Posted by amandaNHT
I've got like 50+ tasks and the amount of tasks is dynamic, because the user can add/remove/change one on another page and the info is stored in the database.
interesting, but again makes no difference as long as the start date boxes have the same class name
Originally Posted by amandaNHT
Also, I still need to be able to call it with PHP after the form is submitted... I use "$_REQUEST['start23date']" or something like that... (where 23 is the automatically-generated id number of the whole task, which gets embedded in everything)
Ok, so I integrated this script but now it submits when the + and - buttons get clicked.. I need it to be able to " + + + + " to add 4 days or something like that and then modify other lines below it as needed before the "submit" button gets clicked because on submit the form is going to alert everyone whose schedule was changed... and I don't want it to send 4 alerts if one task is going up 4 days, and I don't want it to send 7 alerts if task 3 is going up 4 days and task 5 goes down 3 days.
Bookmarks