twilitegxa 0 Newbie Poster

How can I add a value to what displays from a function in my class when a user chooses an option from my drop down menu?

Here is my drop down menu:

<select id="dd">
    <option>Red</option>
    <option>Yellow</option>
    <option>Green</option>
    </select>

Then here is my class:

<script runat="server">
    Class PetName
        Public FirstName As String
        
        Function GetName() As String
            Dim Whole As String
            Whole = FirstName
            Return (Whole)
        End Function
    End Class
</script>

And here is where I set the value to be displayed (I currently have it set to a literal value, but I would like to set it to a value that is set when the user chooses an option in the select menu):

<%
        Dim pet1 As PetName
        pet1 = New PetName
        pet1.FirstName = "Bob"
    %>

And here is where it displays the value on the page: <p>Suggested Pet Name: <%=pet1.GetName%></p> I know I can probably use an if/else statement, but how do I set it up? Do I set it within my Dim statement? If so, how?

Say I want to do this:

if dd.SelectedItem.Text = "Red" Then pet1.FirstName = "Sunny"

elseif dd.SelectedItem.Text = "Blue Then pet1.FirstName = "Ices"

Am I on the right track? How do I actually do this?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.