Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 169
  • Last Modified:

Dynamic DropDown Update

I am trying to add a feature to my CMS that will allow me to order my articles.  The method I am currently trying to use does a cfloop to add the total number of articles for that issue.  So if there are 6 articles there will only be a dropdown box that goes from 1 through 6.  So obviouly i want to be able to give each article a number that will put these articles in that order.

Here is an image to show what my admin looks like
http://www.jhasim.net/order_update.jpg

Here is my current code for displaying this information.

                              <cfoutput query="getArticles">
                              <form name="formOrder" action="update_articleorder.cfm" method="post">
                              <tr onMouseOver="this.style.backgroundColor='EEEEEE';" onMouseOut="this.style.backgroundColor='FFFFFF';">
                                    <td class="adminBlack"><a onClick="previewArticle()" target="windowname" href="../../files/articlefiles/flash/#articleFlash#">#ArticleName#</a></td>
                                    <td class="adminBlack">#ZoneName#</td>
                                    <td class="adminBlack" align="center">#ArticlePages#</td>
                                    <td class="adminBlack" align="center">#ArticleCMECredit#</td>
                                    <td class="adminBlack" align="center"><cfif ArticleReview GT 0>Yes<cfelse>No</cfif></td>
                                    <td class="adminBlack" align="center" width="30"><a href="article_edit.cfm?ID=#ArticleID#" class="adminLink">Edit</a></td>
                                    <td class="adminBlack" align="center" width="50"><a href="article_delete.cfm?ID=#ArticleID#&IssueID=#URL.ID#" class="adminLink" onClick="if(confirm('Click OK to delete the Article: #ArticleName#')){return true}else{return false}">Del</a></td>
                                    <td class="adminBlack" align="center">
                                    <SELECT name="#order_ArticleID#" size="1"><CFLOOP INDEX="LoopCount" FROM="1" TO="#getArticles.recordcount#"><OPTION value="#LoopCount#">#LoopCount#</OPTION></CFLOOP></SELECT>       
                              </form>
                              </cfoutput>







So all i would like to know is how would I go about creating the update.cfm page that would know how to handle the dynamic form name for the select box.  If there is a better method, please show me.

Thank you,
Jeff
0
jeffmace
Asked:
jeffmace
1 Solution
 
danrosenthalCommented:
I probably would name the select something like article_1, article_2, etc. (name="article#order_ArticleID#"), also I would include a list of articles to update by adding this outside of your cfquery:

<input type="hidden" name="article_id_list" value="#valuelist(getArticles.order_ArticleID)#">


Then, after verifying that each number from 1 to article count is represented here, so no 2 articles are given the SAME order I would update like this:

<CFLOOP list="#form.article_id_list#" index="ArticleID">

  <!--- just guessing on the table format here --->
  <CFQUERY ....>
    UPDATE order_Article
    SET article_order = #evaluate("article_"&ArticleID)#
    WHERE order_ArticleID = #ArticleID#
  </CFQUERY>

</CFLOOP>


0
 
jeffmaceAuthor Commented:
Ahhh!  Very Good,  thank you for the idea, I will take it from here.  
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now