Skip to main content
Inspiring
October 22, 2006
Question

OT: Compare PHP recordset to posted data

  • October 22, 2006
  • 19 replies
  • 1025 views
I am populating a form with data from a recordset for user confirmation.
When the form is submitted, I want to compare the submitted data to the
original data and take action if there are any differences in anything.
What would be the best way to do that?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



This topic has been closed for replies.

19 replies

Inspiring
October 24, 2006
Yes - that's a good thing.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
news:ehl1i1$t1u$1@forums.macromedia.com...
> The one nice thing about the JavaScript solution is that you can also
> alert the user if a change is made so that he can update the page. I have
> a site where I alert the user that his document is changed if he tries to
> click any link, which would cause him to lose his changes.
>
> Tom
>
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:ehkscp$mt1$1@forums.macromedia.com...
>> Now I have to go back to Massimo's quote about working at the level of
>> the required result! 8)
>>
>> This sounds over the top....
>>
>> --
>> Murray --- ICQ 71997575
>> Adobe Community Expert
>> (If you *MUST* email me, don't LAUGH when you do so!)
>> ==================
>> http://www.dreamweavermx-templates.com - Template Triage!
>> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
>> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
>> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
>> ==================
>>
>>
>> "Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
>> news:ehjl05$7rj$1@forums.macromedia.com...
>>>> Only problem is that it invalidates the HTML code. I would use a little
>>>> function that runs onload and adds these 'existing' properties to all
>>>> input elements on the fly, so they don't appear in the HTML code.
>>>
>>> Sure, that's a better way to do it. I was just throwing the concept out
>>> there.
>>>
>>> Tom
>>>
>>
>>
>
>


Inspiring
October 24, 2006
The one nice thing about the JavaScript solution is that you can also alert
the user if a change is made so that he can update the page. I have a site
where I alert the user that his document is changed if he tries to click any
link, which would cause him to lose his changes.

Tom


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:ehkscp$mt1$1@forums.macromedia.com...
> Now I have to go back to Massimo's quote about working at the level of the
> required result! 8)
>
> This sounds over the top....
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
> news:ehjl05$7rj$1@forums.macromedia.com...
>>> Only problem is that it invalidates the HTML code. I would use a little
>>> function that runs onload and adds these 'existing' properties to all
>>> input elements on the fly, so they don't appear in the HTML code.
>>
>> Sure, that's a better way to do it. I was just throwing the concept out
>> there.
>>
>> Tom
>>
>
>


Inspiring
October 24, 2006
Now I have to go back to Massimo's quote about working at the level of the
required result! 8)

This sounds over the top....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
news:ehjl05$7rj$1@forums.macromedia.com...
>> Only problem is that it invalidates the HTML code. I would use a little
>> function that runs onload and adds these 'existing' properties to all
>> input elements on the fly, so they don't appear in the HTML code.
>
> Sure, that's a better way to do it. I was just throwing the concept out
> there.
>
> Tom
>


Inspiring
October 23, 2006
> Only problem is that it invalidates the HTML code. I would use a little
> function that runs onload and adds these 'existing' properties to all
> input elements on the fly, so they don't appear in the HTML code.

Sure, that's a better way to do it. I was just throwing the concept out
there.

Tom


Inspiring
October 23, 2006
Michael Fesser wrote:
> Only problem is that it invalidates the HTML code.

You could declare your own namespace to overcome that. That's the
solution that Adobe has adopted with its Spry attributes.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Inspiring
October 23, 2006
.oO(Tom Muck)

>Simple way to do it is to give each field an existing attribute:
>
><input type="text" name="blah" value="<?php echo($somedata);?>"
>existing="<?php echo($somedata);?>" />
>[...]
>
>Untested but the concept should work. Same function for one field or 100.

Only problem is that it invalidates the HTML code. I would use a little
function that runs onload and adds these 'existing' properties to all
input elements on the fly, so they don't appear in the HTML code.

Micha
Inspiring
October 23, 2006

"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:ehjbg8$qre$1@forums.macromedia.com...
> Yeah - seems complex to me.

Simple way to do it is to give each field an existing attribute:

<input type="text" name="blah" value="<?php echo($somedata);?>"
existing="<?php echo($somedata);?>" />

Then use a loop to test the values against existing on submit:

function testFields() {
var dirty = false;
var inputs = document.getElementsByTagName('input');
for(var i=0; i<inputs.length; i++) {
if(inputs .type == 'text' && inputs.value != inputs .existing) {
dirty = true;
break;
}
}
if(dirty) { return true;}
alert("Nothing changed dude");
return false;
}


call it onsubmit using onsubmit="return testFields()"

Untested but the concept should work. Same function for one field or 100.

Tom


Inspiring
October 23, 2006
Yeah - seems complex to me.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
news:ehiukr$bc1$1@forums.macromedia.com...
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:ehil5s$smc$1@forums.macromedia.com...
>> Yes, that would work, too. But how do you discriminate between simply
>> giving a field focus and actually changing something?
>
> That would require a bit more scripting, checking a value against a stored
> value, etc.
>
> Tom
>


Inspiring
October 23, 2006
"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:ehil5s$smc$1@forums.macromedia.com...
> Yes, that would work, too. But how do you discriminate between simply
> giving a field focus and actually changing something?

That would require a bit more scripting, checking a value against a stored
value, etc.

Tom


Inspiring
October 23, 2006
Yes, that would work, too. But how do you discriminate between simply
giving a field focus and actually changing something?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
news:ehikd7$rnt$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:ehg66g$sv2$1@forums.macromedia.com...
>>I am populating a form with data from a recordset for user confirmation.
>>When the form is submitted, I want to compare the submitted data to the
>>original data and take action if there are any differences in anything.
>>What would be the best way to do that?
>
> One thing I have done in the past is to use JavaScript to set a flag if
> the user types into any of the fields. If a "dirty" flag is set, I allow
> the form to be submitted and record updated, otherwise not.
>
>
> --
> Tom Muck
> co-author Dreamweaver MX 2004: The Complete Reference
> http://www.tom-muck.com/
>
> Cartweaver Development Team
> http://www.cartweaver.com
>
> Extending Knowledge Daily
> http://www.communitymx.com/
>