#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    9
    Rep Power
    0

    Exclamation cfml + javascript = populating text box?


    I wanted to populate a text field and possibly refresh the page so it can output a query correctly (keeping the populated
    data so coldfusion will see that data and populate the field correctly when it interprets the code?). My reasoning behind it is i
    have a page that querys a database selecting everything in a table. (using coldfusion) then populates a dropdown with a
    certain column of that data (on load). I want it to populate the text field depending on which option you select in the
    dropdown (with another column of data). Is this possible? I know how to populate the field with my column (#sftr_sn#) but i cant make it interpret this because this is selected AFTER coldfusion (serverside) interprets the variables! any help would be much appriciated! thanks!
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    3
    Rep Power
    0
    So you have two fields.

    And based on what is selected in the first you want a different list spit out in the 2nd?

    You could have a javascript command on the first dfield that submits a form to the same page. If that form variable is defined you could query and populate the 2nd select.

    Is that what you are trying to do?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    9
    Rep Power
    0
    to some degree, its not populating to a second list, i.e. its not a progressive dropdown. rather its populating a text field. heres an example. lets say i populate a dropdown list with a column named sftr_nm (software name) and when i choose one i want it to populate the text field below it with the corrosponding sftr_sn (software serial no.). i know its possible and i hadnt thought of having it submit to the same page, that might work. ill try it. any other ideas plz plz let me know. thanks!
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    3
    Rep Power
    0
    The easiest way that I know how to do would be to submit to the same page and query for the software serial.

    It is also possible to do all the queries on the first page and hold them in javascript arrays. I know that this is possible but I'm not real good with the JS.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    9
    Rep Power
    0
    i had thought of that but was not sure how to populate the arrays with the CF output =/ if anyone knows that would be good (eventually im going to have to requery because of length of table, but for nbow arrays would be nice just as a convience.). thanks ethan, much appriciated =)
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    richmond, va
    Posts
    9
    Rep Power
    0

    populate arrays with javascript


    okay, lemme dig up the code..

    /me hopes this will display right

    I'm just going to paste something from an app I did a few weeks ago and then if you have any questions you can ask, I think that will work better than me trying to generalize it.
    Code:
    <script language="JavaScript">
    	var tourlist=new Array();  //array to hold tours
                    function init(){
    	<cfset index="0"> // index to array
    	<cfoutput query="tourslist">
    		tourlist[#index#]={
    						DateID: "#DateID#",
    						Time: "#time#",
    						Notes: "#notes#",
    						ReqStaff: "#reqstaff#",
    						Spaces: "#spaces#",
    						TourID: "#TourID#"
    					};
    	<cfset index=IncrementValue(index)>
    	</cfoutput>
    So yeah, that should do it. Just put the cfoutput inside your script tag.
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    9
    Rep Power
    0
    hrmm so it will output the first peice of info from each column into a array, and then increment the array (index) number and then do the same untill it is out of columns? i see what you are saying but im not seeting if it is gonna populate just one or multiple parts of the array not just the 0. if this works you're officially my hero of the week haha, thanks.

    ^--- I hope that makes sense to you I'm quite tired today =/
    Last edited by firest0rm; July 9th, 2003 at 02:48 PM.

IMN logo majestic logo threadwatch logo seochat tools logo