Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool document.write woes / page clearing

    Greetings-

    Currently, I am working on a page that has a combo-box (populated from a database) where a user will select a value. When something is selected from the combo-box, another combo box will appear below with the same populated values.

    The way I have this set up, thus far, is that a javascript function is created (GenerateElements) with a variable passed to it, Number, so that I can generate ComboBox1, ComboBox2, etc. by tacking the passed variable number on to the end.

    The function does work. It outputs everythign fine, however not exactly how I am looking for it to do so. I am basically looking for a += rather than just an =, if you catch my drift ;-)

    The pages contents seem to be lost when I call the function, which does use document.write, opposed to leaving all the previous boxes on the screen, and merely creating a new one at the end.

    The "best" way I have seen through looking around, is to have hidden elements that become visible (divs) but this doesn't exactly work for my situation, as there is no predefined maximum number that are to be selected. Instead, I would prefer to use a function (obviously having to change something over my current) to create a new combo box after what is currently on the screen. Could even be concatenating to the end of a div or iFrame if that is possible, so long as I am able to use the values for POST data.

    Is there any way to realistically achieve this? I've considered frankensteining this project and just outputting the page source to a text document and re-importing after every change, but want to avoid this for obvious, obvious reasons.

    I don't believe there aren't any coding samples I could attach which would help explain the problem any better, just basic document.write issues, and looking for a workaround.

    Thanks in advance!

    David

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    look into innerHTML i believe that is what you may need, how many comboboxes are you looking on generating here?

  • #3
    New to the CF scene
    Join Date
    Mar 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, more background on the project:

    Basically, this is used for reporting so that agents/people can search by any statistic in our database (using the mysql_num_fields for itteration, and mysql_field_name to populate the combo box), and punch in a value (so 2 boxes per, but figured easiest to say only one combo box so as to not dwell on parts I have figured out).


    I'm not sure how many combo boxes will be needed, but I can't forsee needing more than 10, so that was my logical cutoff if I couldn't create a workaround.

    like... if someone were to wish to find out return % on head of households for agent xx/yy that are female and in the 12345 zipcode and under age 60.... I mean, I don't have any way of predicting what someone wants statistics for so I am just doing my best to incorporate everything they could want to search for by giving them the options

    Edit:

    From the looks of things with innerHTML, I will be storing document.getelementbyid("name").innerhtml to a variable, then tacking my combo box coding onto the end, then setting document.getelementbyid("name").innerhtml to the variable with the added coding. Giving it a try, will follow up if it works

    Thanks again for the response
    Last edited by Shindere; 03-21-2005 at 07:20 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •