Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page not updating?

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Hello all!

I have created a .cfm which deletes / adds records to a DB table via users selecting / deselecting check boxes. The page is viewed in a child window and each time they enter the page, their previous selections are already checked.

The page works fine and the update is completed but if the user re-enters the page to modify their selections, the page shows their old selections even though the list looks at the updated table. To view the page as it should be, you have to manually refresh the page via right-clicking and selecting 'refresh' even though you have just opened it ??

Does anyone have any idea how I can avoid this problem and explain why this is happening???

Thanks very much

Rachel
 
-> don't cache it (plenty of thread on thi matter in the html&css + javascript forums, just perform a search (the search tab is above the thread list when you enter the forums)
-> use some javascript function and call document.reload(true) to force the reload ------
please review FAQ183-874 - this will help you to get the best out of tt
[ "you" is not someone in particular - don't take it too personnal ]
 
I have had a look within HTML, CSS and javascript sections as advised but was unsuccessful in finding anything.

You said don't cache it but unless this is done automatically, I don't think I have! The previous selections are checked via a DB search which checks the values they have selected again all the possible values.

I have tried using the javascript document.reload(true) but this doesn't seem to make any difference.

See below for the main part of the page which displays the list where previous selections are checked:

<CFOUTPUT QUERY=&quot;GET_LOCALITY&quot;>
<CFSET LOCALITY = #LOCALITY_ID#>
<CFSET CHECKED = &quot;NO&quot;>
<CFLOOP QUERY=&quot;PREVIOUS_SELECTIONS&quot;>
<CFIF #FIELD_VALUE# IS NOT #LOCALITY#>
<CFSET CHECKED = &quot;NO&quot;>
<CFELSE>
<CFSET CHECKED = &quot;YES&quot;>
<cfbreak>
</CFIF>
</cfloop>
<tr>
<td width=&quot;5&quot; bgcolor=&quot;7fa9ae&quot;> </td>
<td bgcolor=&quot;cfdee0&quot; width=&quot;440&quot;><font face=&quot;MS Sans Serif&quot; size=&quot;1&quot;>
#LOCALITY_NAME#
</font></td>
<td bgcolor=&quot;cfdee0&quot; width=&quot;5&quot;>
<div align=&quot;center&quot;>
<CFIF #CHECKED# IS &quot;YES&quot;>
<CFinput type=&quot;checkbox&quot; name=#LOCALITY_ID# value=#LOCALITY_ID# CHECKED>
<CFELSE>
<CFinput type=&quot;checkbox&quot; name=#LOCALITY_ID# value=#LOCALITY_ID#>
</CFIF>
</div>
</td>
</tr>
</CFOUTPUT>

The code below is from the second page within the child window which updates the table with the users selections:

<CFQUERY NAME=&quot;DeleteSelections&quot; DATASOURCE=&quot;WebUser&quot;>
DELETE FROM JOB_SEARCH_CRITERIA
WHERE
OFFICER_ID = 'OFF'
AND DEPARTMENT_ID = 'DEPT'
AND FIELD_NAME = 'LOCALITY.LOCALITY_ID'
</CFQUERY>
<cfset selections = StructKeyArray(FORM)>
<CFLOOP INDEX=&quot;COUNT&quot; FROM=&quot;1&quot; TO=&quot;#ARRAYLEN(selections)#&quot;>
<cfoutput>
<CFIF #selections[count]# IS NOT &quot;FIELDNAMES&quot;>
<CFQUERY NAME=&quot;InsertSelections&quot; DATASOURCE=&quot;WebUser&quot;>
INSERT INTO
JOB_SEARCH_CRITERIA(DEPARTMENT_ID,OFFICER_ID,FIELD_NAME,FIELD_VALUE) VALUES('DEPT','OFF','LOCALITY.LOCALITY_ID',#selections[COUNT]#)
</CFQUERY>

</CFIF>
</cfoutput>
</CFLOOP>

<SCRIPT language=&quot;javascript&quot;>
window.opener.document.location.reload();
close();
</SCRIPT>

Any ideas?

Thanks again

Rachel
 
Try this syntax:

<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;LOCALITY_ID&quot;
VALUE=&quot;#GET_LOCALITY.LOCALITY_ID#&quot; <CFIF #GET_LOCALITY.LOCALITY_ID# IS &quot;#LOCALITY#&quot; CHECKED</CFIF>>

I think you can use this syntax to streamline your code a little. I'm not suggesting the code is perfect for you, but using the cfif as a sort of &quot;inline&quot; check/no check test should be a viable direction.

Good luck ... John Hoarty
jhoarty@quickestore.com
 
Thanks for the help again. Unfortunately, the suggested code brought back an error - I don't think that it liked the <cfif> within the form input tag.
 
Rach

I use that all the time and I've been doing forms for years and years. In-line is definitely the way to go. What error did you get?

As I said, I didn't think the code was exactly what you were looking for. I just thought to give a new direction. I'll be glad to help you get it right.
John Hoarty
jhoarty@quickestore.com
 
&quot;You said don't cache it but unless this is done automatically, I don't think I have&quot;
it IS done automatically, check your browser's cache to &quot;see&quot; it !!!!

&quot;window.opener.document.location.reload();
close();&quot;

it's a popup ??

&quot;I don't think that it liked the <cfif> within the form input &quot;
this can't be the problem as i've been using this a lot in my previous project (and it was working fine, really) - but it definitly doesn't like having #variable# inside cfifs - neither missing > !!!!
<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;LOCALITY_ID&quot;
VALUE=&quot;#GET_LOCALITY.LOCALITY_ID#&quot;
<CFIF GET_LOCALITY.LOCALITY_ID IS &quot;LOCALITY&quot;> CHECKED</CFIF>
>





------
please review FAQ183-874 - this will help you to get the best out of tt
[ &quot;you&quot; is not someone in particular - don't take it too personnal ]
 
Take a look at this thread, I think it may be of some help:

thread232-110645 - tleish
 
Variables inside cfifs inside form inputs are not a problem.

Here's a checkbox from an app I wrote that is used constantly where I work:

<INPUT TYPE=checkbox NAME=&quot;LunchGuest#editname.CurrentRow#&quot; <cfif #editname.LunchGuest# is 1>CHECKED</cfif>> John Hoarty
jhoarty@quickestore.com
 
no i was speaking of pound signs
people tend to overuse them, even where they are not needed - sometimes cf has troubles parsing it ------
please review FAQ183-874 - this will help you to get the best out of tt
[ &quot;you&quot; is not someone in particular - don't take it too personnal ]
 
I have played with the code and as iza noticed, it was missing a '>' - typical.

The code obviously doesn't through an error any more but I don't think that I can use the suggested code for what I am trying to achive.

Below is how I used it so far:

<CFOUTPUT QUERY=&quot;GET_LOCALITY&quot;>
<tr>
<td width=&quot;5&quot; bgcolor=&quot;7fa9ae&quot;> </td>
<td bgcolor=&quot;cfdee0&quot; width=&quot;440&quot;><font face=&quot;MS Sans Serif&quot; size=&quot;1&quot;>
#LOCALITY_NAME#
</font></td>
<td bgcolor=&quot;cfdee0&quot; width=&quot;5&quot;>
<div align=&quot;center&quot;>
<CFLOOP QUERY=&quot;PREVIOUS_SELECTIONS&quot;>
<CFSET LOCALITY = #FIELD_VALUE#>
<CFIF #GET_LOCALITY.LOCALITY_ID# IS #LOCALITY#><CFBREAK></CFIF>
</cfloop>
<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;#LOCALITY_ID#&quot;
VALUE=&quot;#LOCALITY_ID#&quot; <CFIF #GET_LOCALITY.LOCALITY_ID# IS &quot;#LOCALITY#&quot;> CHECKED</CFIF>>

</div>
</td>
</tr>
</CFOUTPUT>

The way it needs to work is that for every record it displays (<CFOUTPUT QUERY=&quot;GET_LOCALITY&quot;>), I need to loop through 'PREVIOUS_SELECTIONS' to find a matching value. If a match is found then the checkbox needs to be checked.

At the moment, the code only ever brings back one checked box regardless of their previous selections / how many matches there are.

....and unfortunately, the page still isn't refreshing properly.

I was unsure whether you were asking if the page views in a popup (iza that is) in your last message - Yes it is

Thanks again, again!

Rachel

 
Why not try this, rather than looping through the PREVIOUS_SELECTIONS query, make a value llist of it. I'm not sure what goes where I have FIELD_NAME, but it may work as is:

<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;#LOCALITY_ID#&quot;
VALUE=&quot;#LOCALITY_ID#&quot; <CFIF (`#ValueList(PREVIOUS_SELECTIONS.FIELD_NAME)#') CONTAINS &quot;#LOCALITY_ID#&quot;>CHECKED</CFIF>>
John Hoarty
jhoarty@quickestore.com
 
what you want to do is :
diplay all the cities names, and for each city name, if it has been selected before, then check the checkbox - right ?
and your problem is that
1 - whatever you do there is only one checked checkbox
2 - and it's the one of the PREVIOUS query
right ?

* did you double (triple !!) check the QUERIES : do they return what you expect ? are you sure the previous_selections one gets re-executed every time ?
* did you try to output the queries's results, to make sure there actually were more than 1 checkbox to check, and that it was different from the previous ?
* are you sure of their ORDER : i mean, if previous query is executed first then it might not have the results of the current one
* did you output field_value everytime, just to visually make sure you're comparing to the right value ?
* did you do &quot;view source&quot; on the popup to check that the generated code was what you expected ? sometimes it doesn't display just because you'd forget to close a tag

* because i think your piece of code should behave the way you expect it to, provided the above are checked
so if this is the case, just prevent the caching (there are hundred threads on this subject - basically you have to either use meta tags or add a random number/date-time stamp to fool the browser) ------
please review FAQ183-874 - this will help you to get the best out of tt
[ &quot;you&quot; is not someone in particular - don't take it too personnal ]
 
Thanks for that john, the code works a treat - cuts the code down loads!

Unfortunately though, I still have the same problem with the page refreshing properly when I re-enter.

I have tried adding in the following code which is generated via onload within the <body>:

function refresh()
{
document.reload(true);
}
....but it doesn't make the slightest difference!

I have still got other methods to try out from the other thread that was suggested earlier but could this problem have anything to do with the fact that I am posting the form to another page within the child window which updates the table instaed of straight to the parent window?

Cheers

Rachel
 
Tell a lie, it doesn't work - how gutted am I!! Extra values are being checked now. I am assuming that I am using 'contains' when the values of FIELD_VALUE are numeric??

Updated code used:

<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;#LOCALITY_ID#&quot;
VALUE=&quot;#LOCALITY_ID#&quot; <CFIF (#ValueList(PREVIOUS_SELECTIONS.FIELD_VALUE)#) CONTAINS &quot;#LOCALITY_ID#&quot;>CHECKED</CFIF>>
 
Don't panic (yet). Try using &quot;QuotedValueList&quot;:

<INPUT TYPE=&quot;CHECKBOX&quot; NAME=&quot;#LOCALITY_ID#&quot;
VALUE=&quot;#LOCALITY_ID#&quot; <CFIF (#QuotedValueList(PREVIOUS_SELECTIONS.FIELD_VALUE)#) CONTAINS &quot;#LOCALITY_ID#&quot;>CHECKED</CFIF>> John Hoarty
jhoarty@quickestore.com
 
Actually, I don't think it should matter if you use quotedvaluelist or not. I'd start checking those queries and also, make sure that physically refreshing gives the desired result every time. I think you may be getting down to programmatic (logic) issues at this point. Keep us posted. John Hoarty
jhoarty@quickestore.com
 
I have used QuotedValueList as suggested and this seems to work - Thanks!

I am still having the same problem with the refresh though, can anyone offer any advice as I have looked at another thread for help but haven't had much luck!

Thanks again
 
Can I use <CFCACHE> ? with the flush.expireurl attributes - if so, can anyone explain how to use it as the explanation in the CFML reference doesn't make that much sense to me

Thanks

Rachel
 
Rach:

In place of
<SCRIPT language=&quot;javascript&quot;>
window.opener.document.location.reload();
close();
</SCRIPT>

in your child window, try just putting this:

<body onLoad=&quot;reload();&quot;>

John Hoarty
jhoarty@quickestore.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top