very easy, please help: Field

databases United States
  • 19 years ago

    i would like to send the value of a region to my MS Sql database when a user registers with a form and chooses a country.
    the problem is that i dont know how to set the onsubmit action in the form with the function. i am not sure the function is correct either. I just started working with asp, and my manager wants me to finish this project by today. it is very frustrating, so i would greatly appreciate any help.


    this is my function:
    e.g.


    <%
    Function Region
    if glass.Value("country") = "United Kingdom" then
    glass.Value("region") = "North"
    end if
    End Function
    %>


    Within the form i have the following value:


    <input type="hidden" value='<%glass.Value("region")%>' name='region'>


    thanks for any ideas,
    natalia

  • 19 years ago

    I don't have any experience programming in ASP, but looking from a VBA point of view, I think you should consider at least the next:


    Instead of the function you described:


    <%
    Function Region
    if glass.Value("country") = "United Kingdom" then
    glass.Value("region") = "North"
    end if
    End Function
    %>


    you should use something like:


    <%
    Function Region
    Select Case glass.Value("country")
      Case "United Kingdom": glass.Value("region") = "North"
      Case "South Africa": glass.Value("region") = "South"
      Case ...........
      Case ...........
    End Select
    End Function
    %>


    I'm just not sure if ASP uses exactly the same source as VB... A "Select Case" statement would run through your code a lot faster and would make it better readible. Use "Select Case .... End Select" always when a variable has multiple possible outcomes... The "If ... Then" only when you have like up to 4-5 options...


    If you're planning to use the data frequently you could also try loading it into an array at the start of your form...


    If you use only one single level of quotation marks " " then always use the same ones, that's a lot easier to read your code later and to get mistakes out. Instead of your line:


    <input type="hidden" value='<%glass.Value("region")%>' name='region'>


    You'd get this:


    <input type="hidden" value='<%glass.Value("region")%>' name="region">


    I hope this helped you a bit allthough the deadline already went dead...


    BTW: You know why a deadline is called a deadline? 'Cause you're DEAD if you don't meet the LINE... ;-)


    Regards,


    Thamar.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“To iterate is human, to recurse divine” - L. Peter Deutsch