Announcement Announcement Module
No announcement yet.
Session map & javascript Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Session map & javascript

    I have a select box which lists instructors full names (from a session
    variable: session.eligibleInstructor, created in the LoginController
    from a query of a view that returns fullname and email, so
    session.eligibleInstructors.FULLNAME returns the fullname and
    session.eligibleInstructors.EMAIL returns the email, session.eligible
    Instructors returns both:

    def eligibleInstructors = dbConnection.rows("select FULLNAME, EMAIL
    from zV_eligibleInstructors ORDER BY LASTNAME")
    [[FULLNAME:Berg, Douglas, EMAIL:[email protected]], [FULLNAME:Askov,
    Michael, EMAIL:[email protected]], [FULLNAME:Abba, Jasmine,
    EMAIL:[email protected]], ...

    I want to update a textfield with the selected instructors email
    address when the instructor is selected in the selectbox. I know my
    javascript is capturing the selected instructor (because I did an

    selectedInst: $(
    function() {alert($(

    but my controller action (updateSelect) is not doing anything:

    def updateSelect = {

    println("UpdateSelect reached")

    println("Params: " + params.any())
    def selectedInstEmail = dbConnection.firstRow("select EMAIL
    from zV_eligibleInstructors where FIRSTNAME=?",
    render selectedInstEmail


    I have tried multiple ajax-type callbacks , even a remoteFunction in
    the "onchange"event. I realize I should haven't to go back to the
    database to get the selected Instructors email because it's already
    avilable in the session variable eligibleInstructors, but how do I
    access the EMAIL value using the FULLNAME as the key? Do I even need
    to use Ajax for this? What is the "best practice? I have looked at
    hundreds of webpages for the answer but none seems to quite touch on
    this exact issue. Even if I could just get the controller action to
    fire, that would be a huge step forward. Do you have any suggestion on
    how to achieve this? Any suggestions will be greatly appreciated.