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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Dynamic Form Build - Select Field

    Does Anyone Have An Alternative To This Code To Optimize It.

    I Am Creating A Dynamic Form Based On Some Preliminary Information Captured. I Am Writing Select Fields Based On A Predetermined Option Selected. In This Example The Variable Passed Is "DegreeOfDifficulty" Which May Be 0-5. When I Create The Dynamic Form, I Want The Select Field To Reflect The Predetermined "DegreeOfDifficulty" As The Selected Value. In The Event Of The "0" Value, The Default Case Else Kicks In.

    The Code Below Works; However, I Have Other Fields That Have A High Number Of Selections, And This Code Seems Redundant.

    I Am Thinking An Array And A Loop Of Somekind Will Be More Efficent, But I Am Not At A Level To Write That! :-(

    Any Suggestions Or Direction Would Be Appreciated. TIA


    Code:
    With Response
        .write( "<select size='1' name='DegreeOfDifficulty' style='font-family: Arial Narrow; font-size: 10pt'>" ) 
    Select Case DegreeOfDifficulty 	
        Case 1
       	.write( "<option value='0'>Select Level</option>" )
        .write( "<option selected value='1'>Beginner</option>" )
        .write( "<option value='2'>Junior</option>" )
        .write( "<option value='3'>Intermediate</option>" )
        .write( "<option value='4'>Advanced</option>" )
        .write( "<option value='5'>Expert</option>" )    
        Case 2
       	.write( "<option value='0'>Select Level</option>" )
        .write( "<option value='1'>Beginner</option>" )
        .write( "<option selected value='2'>Junior</option>" )
        .write( "<option value='3'>Intermediate</option>" )
        .write( "<option value='4'>Advanced</option>" )
        .write( "<option value='5'>Expert</option>" )
        Case 3
       	.write( "<option value='0'>Select Level</option>" )
        .write( "<option value='1'>Beginner</option>" )
        .write( "<option value='2'>Junior</option>" )
        .write( "<option selected value='3'>Intermediate</option>" )
        .write( "<option value='4'>Advanced</option>" )
        .write( "<option value='5'>Expert</option>" )
        Case 4
       	.write( "<option value='0'>Select Level</option>" )
        .write( "<option value='1'>Beginner</option>" )
        .write( "<option value='2'>Junior</option>" )
        .write( "<option value='3'>Intermediate</option>" )
        .write( "<option selected value='4'>Advanced</option>" )
        .write( "<option value='5'>Expert</option>" )    
        Case 5
       	.write( "<option value='0'>Select Level</option>" )
        .write( "<option value='1'>Beginner</option>" )
        .write( "<option value='2'>Junior</option>" )
        .write( "<option value='3'>Intermediate</option>" )
        .write( "<option value='4'>Advanced</option>" )
        .write( "<option selected value='5'>Expert</option>" )
        Case Else
       	.write( "<option selected value='0'>Select Level</option>" )
        .write( "<option value='1'>Beginner</option>" )
        .write( "<option value='2'>Junior</option>" )
        .write( "<option value='3'>Intermediate</option>" )
        .write( "<option value='4'>Advanced</option>" )
        .write( "<option value='5'>Expert</option>" )
    End Select
        .write( "</select>" )
    End With

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    Bugaha, NE
    Posts
    330
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here's a simple dynamic select box. See the attached txt file. Each line of it checks the value of "DegreeOfDifficulty" writes "selected" if the value of the variable matches that of the row of the select box.

    By the way, don't know if you realize, but the style:

    with response
    .write
    .write
    .write


    is actually slower. Chances are, you probably aren't writing anything so complex that causes major performance loss, but it is a bit slower than response.write on every line, or even just putting <% %> tags in your html, as I did here.
    Attached Files Attached Files

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Plano, Texas
    Posts
    113
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank You! Not only for the code, but the tip on .write!
    Your Coding handle will reside as a credit in my code.

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Bugaha, NE
    Posts
    330
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No problem. Glad to help.

    Like I said, the .write thing probably isn't something that would have caused a major performance hit, but I read an interesting article on it a few months back. whammy gave me the link to it.


  •  

    Posting Permissions

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