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 11 of 11
  1. #1
    New Coder
    Join Date
    Aug 2002
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Drop downs on edit page.

    I have some drop downs on my edit page. I would like to have the current value comming from the database displayed and change it with the dropdown if needed. I have it working but if I make no changes, the fields get updated to null.
    Any help would be great.

    eRs is the one row record that's being editted.
    Rs is the recordset that holds the list of names.



    getEmpRs()'
    <table name=resources align=left cellpadding=0 border=0 width=540 style="position:relative; left:0; top:0" bgcolor=DeepSkyBlue>

    <thead>
    <tr><td><font size=4 color=Black>Resources</td></tr>
    </thead>

    <tr><td align=right>Business Analyst:</td><td>
    <Select Name=EmpDropDwn1 align=left><%
    Response.Write("<option value=>"&eRs("ANALYST"))
    do while Rs.EOF=false
    Response.Write("<option value='"&Rs("emp")&"'>")
    Response.Write server.HTMLEncodeRs.Fields"emp")) "</option>")
    Rs.MoveNext
    loop
    %></Select></td>
    </tr>

  • #2
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is this supposed to be the current value ?

    Response.Write("<option value=>"&eRs("ANALYST"))

    Because it has no value. Only a lable.

  • #3
    New Coder
    Join Date
    Aug 2002
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You are correct as usual. I fugured it out by looking at the source when I ran the page. Here is the code I came up with and it works.

    Thanks for your help!

    Response.Write("<option value='"&eRs("ANALYST")&"'>")
    Response.Write eRs("ANALYST")& "</option>"

    do while Rs.EOF=false

    Response.Write("<option value='"&Rs("emp")&"'>")
    Response.Write(server.HTMLEncode(Rs.Fields("emp")) & "</option>")
    Rs.MoveNext

    loop

  • #4
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just a small remark : try to make your output xhtml-valid, and use " instead of ' for atributevalues. Like
    Code:
    Response.Write("<option value=""" & eRs("ANALYST") & """>" & eRs("ANALYST") & "</option>"
    
    do while Rs.EOF=false
       Response.Write("<option value=""" & Rs("emp")&""">" & server.HTMLEncode(Rs.Fields("emp")) & "</option>")
       Rs.MoveNext
    loop
    Also, now you have the current value at the top. But it will probably appear double. It's nicer to just have it once, and in the right sequence (so not the current at the top and then the sequence. Like
    Code:
    do while Rs.EOF=false
       Response.Write("<option value=""" & Rs("emp")&"""")
       if Rs("emp") = eRs("ANALYST") then 
         response.write(" selected=""selected""") 
       end if
       response.write(">" & server.HTMLEncode(Rs.Fields("emp")) & "</option>")
       Rs.MoveNext
    loop
    (it's also better to use Rs.Fields("emp").Value instead of Rs("emp"), and if its a rather large recordset, to store the recordset in an array, using GetRows --> run a search here for more info)

  • #5
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    raf, I'm trying to get my fellow developers to write XHTML valid code, as well.

    My arguments are:

    1. It's the most up-to-date HTML
    2. It's backwards compatible, and forwards compatible!
    3. It is MUCH cleaner code
    4. Less problems with syntax errors, etc.
    5. It's a STANDARD! Standards are GOOD! I think that's the main point... developers need to realize we're on the same team and we should be coding to the same standard, so we're all on the same page...

    Some of them are like "Why should I learn that? The code I've been writing for five years still works" ...which isn't always true, and I've pointed that out every time I've had to help them fix it - but I can see their point as well at times, even though I HATE to write sloppy code.

    Example of some of the stuff I have to deal with (not the worst, and not the best, but an example):

    <font face = arial +2><b><input type = text name = example value = "hi there"></b></font>



    No quotes around attributes, spaces which shouldn't be there (which by the way screws up the current implementation of Mozilla, at the least!), font tags everywhere, unclosed tags, etc. ...and don't even ask what that "+2" is supposed to be, although I think it was an attempt someone made at font sizing?

    I've got a few links that suggest reasons why people should write compliant code, and I think I've started to convince a few of them, but I was wondering if you had any additional input on this subject.

    Personally I think just the modular aspect (i.e. stylesheets, no ugly font tags, external (and cached!) scripts) is enough it itself, not to mention browser compatibility, etc.... the only challenge is convincing other people to start writing clean (and standards compliant) code. :|

    I've helped all of them figure out solutions enough that they're starting to see my point (and when sloppy or non-compliant code is the problem I make sure I point it out!), but any further nudges in this direction would be helpful.
    Last edited by whammy; 10-22-2003 at 04:51 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #6
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well, I never understand why people don't simply agree with standard-compliane. I think it's just the only sensible thing to do.

    - if you write valid HTML, then writing valid XHTML is like reading one or two pages of changes
    - the number of canvasses is growing each year. cellphones, pocket pc's, palms, ... If you want to send content to those with an accaptable layout, then you need to use valid XHTML and CSS. And in the future, we're surely gonna be writing XML and XSL. So why not grow into that now?
    - every party needs to play it's role. Codegenerators and developpers need to produce valid code, browser-builders need to produce standard-compliant browsers (start working, Gates), users should only use standard compliant browsers.
    - if you care about your users, then you want to enable them to 'read' your site. And this also goes for (visually) inpaired users. If there werent standards, then it would be impossible to create screenreaders etc. So start writing valid code so that screenreaders can correctly process your code.
    - one of the current evolutions are databrokering and integrating of 'independ' application. They need to speak the same language. Standards need to be set and followed to allow optimal use of content and to be able to apply your own look and feel to other peoples content
    - if everyone follows W3C-standards, then this will make development cheaper

  • #7
    New Coder
    Join Date
    Aug 2002
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you raf for the elegent code. Thanks both of you for the advice on xhtml. I will start using it today. My background is Oracle development and I have only been working with ASP, javascript and HTML for a few months, so I am very green. Often I am just trying to get things to work because my employer has not sponsered any formal training. Everthing I know I get from here, w3schools and devguru, so I really appreciate the input.
    I am always trying to get new developers to write their SQL and PL/SQL to standards and it's sometimes lie pulling teeth.

    Thanks again!!!
    Ray

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Actually w3schools is a great place to learn XHTML.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #9
    New Coder
    Join Date
    Aug 2002
    Posts
    89
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was wondering if there is a way that the user could start typing the analyst name in the dropdown and have the name pop in if it's in the recordset and if not add the name to the database?

  • #10
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes. Very well possible, but this will probably be done in javascript (which i don't know well + which i try to avoid.)

    I've seen some threads about this lookup function so if you run a search here ...

    But i would just stick with the dropdown. If the list isn't to long, it's not a real problem for the users to run through it. If it's rather long, then i would cut it up and let the user select the first letter. (by displayng the letters fro a to z as links with that letter in the querystring)
    Processing large recordsets and sending the complete list to the browser will take up to much resources.

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by elcaro2k
    I was wondering if there is a way that the user could start typing the analyst name in the dropdown and have the name pop in if it's in the recordset and if not add the name to the database?
    See this thread: Auto-selecting options based on continuous keystrokes
    Check out the Forum Search. It's the short path to getting great results from this forum.


  •  

    Posting Permissions

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