SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    ********* Addict DLG_1's Avatar
    Join Date
    Jun 2000
    Location
    Texas, USA
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Stupid DOM problems! Programmatically creating a dom element, but error is thrown.

    I have a dynamically created form.
    I collect the values and then insert into a database. When the user views their previous information is extracts this info from the database and populates the form.
    I've got everything working except the piece that works with the drop down menu.
    here's my code:
    And yes, I'm intermingling vbscript (server side) with javascript (client side)
    Code:
    	   ddm = document.form.cboLiabClass<%=i%>;
    	   for (i=0;i<ddm.length;i++){
    		 if  (ddm.options[i].value == parseInt(val)){
    		  ddm.selectedIndex = i;
    		  break;	   
    		 }
    	   }
    nothing happens.

    but when i change
    ddm = document.form.cboLiabClass<%=i%>;

    to

    ddm = document.form.cboLiabClass1;

    Then it works.

    When I look at the source code it's
    ddm = document.form.cboLiabClass1;

    Thanks,
    Sam

  2. #2
    SitePoint Addict silent's Avatar
    Join Date
    Jun 2004
    Location
    Roaming North America
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    2 immediate suggestions...

    You could try trimming the <%=i%> to make sure there's no whitespace around it. (Also look for crlfs...)

    Or you could wrap the JS statement in an eval();

    HTH

  3. #3
    &#083;itePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would suspect that you are trying to assign the variable before the document has built at the client, so that the object isn't yet available. Try calling your assignment code through onload.

  4. #4
    ********* Addict DLG_1's Avatar
    Join Date
    Jun 2000
    Location
    Texas, USA
    Posts
    597
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, none of those suggestions worked, I just took the processing back to asp and when the session value = the database value I printed a "selected" attribute in the input tag.


    it works, but not what I wanted.

    thanks anyway guys!!!
    dlg


Bookmarks

Posting Permissions

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