coldfusion position scrollbar

Posted on 2012-09-10
Last Modified: 2012-09-12

I have a page like this,
- the top part is
a form containing serveral textboxes and dropdown lists as filter + a button called "Filter". this button when click will call function to query database

- the second part is
      a table to display retrieved records, plus a input column for user to enter comment on each row.
 a button called "save" to save comment if there is any.

the retrieved records could be many. my question is when user work on entering comment on record which is close to the page bottom, how can the page go back to the modified record after the page reload due to button "save" click.

Please provide code example in detail since I am new.
Thanks much.
Question by:e126319
    LVL 53

    Expert Comment

    Give each record a unique id.  then on the server when you go back to the page add #and the id to the end of the page url.


    Author Comment

    Thanks for the reply, I have a javascript function to catch which cmnt field is clicked, and assigned it to a hidden field. could you provide a detailed steps how to use it, a code example?
    LVL 53

    Assisted Solution

    Okay if the var contains the id then you just append it to the url:

    If the page you are sending back is http://mypage.html and the id of the comment was comment1 then the url going back should be would be http://mypage.html#comment1

    I am not a cf expert so the best I can do as far as code is give you the PHP I use for such things:

    $url='http:/'. $_SERVER[REQUEST_URI] . $hash;
    header("Location: $url");

    LVL 51

    Expert Comment

    (no points, COBOL already answered your question ...)

    Are you posting the form to the same page or to a separate action page?

    Author Comment

    save button will save data and refresh the current page. I have a hidden field to keep the clicked field name,  here is what I have
    <cfform name="form_Process" method="post" action="index.cfm?page=processWork&###Form.pos#"
    pos is the hidden field name, and its value is the clicked field name. when run, I got error "pos is not defined in Form..." how do I reference form field in action property?
    LVL 51

    Accepted Solution

    form variables don't exist until after the form is submitted. You must use javascript to get the position before it's submitted.  You can also use it to change the action of a form:

                    var someForm = document.getElementById('idOfForm');
                    someForm.action = 'newurlhere.cfm.....'; // changes the action
                    someForm.submit(); // submits a form

    Or you could use jquery/javascript to scroll to the element when the page loads

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now