How do I Use option value in construct 2

0 favourites
  • 5 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • In html I can make a dropdown like this:

    <form action="myaction">
      <select name="cars">
        <option value="volvo">Volvo XC90</option>
        <option value="saab">Saab 95</option>
      </select>
      <input type="submit" value="Submit">
    </form>[/code:3b3j56rn]
    
    In construct 2 it seems to me that I only have a text for the option.... something like:
    [code:3b3j56rn]
    <option>Volvo XC90</option>
    [/code:3b3j56rn]
    and I can't find a way to show text and send a different value.
    Is this missing?
    Tank you!
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • What are you trying to do?

  • I read with ajax a .txt file containing (i.e):

    Server A|192.168.0.1|Server B|192.168.0.1

    with tokenat i populate the dropdown menu.

    So I have a dropdown like

    |--- Server A

    |--- Server B

    I would like to have

    |--- Server A (VALUE 192.168.0.1)

    |--- Server B (VALUE 192.168.0.1)

    The user select the Server and connect to the associated ip address in value

    Anyway I'have found a workoaround. The Ajax is still populated so I use:

    tokenat(AJAX.LastData,(ServerList.SelectedIndex*2)-1,"|")
    [/code:6cn4klkf]to get the ip  associated to the selected server
  • By dropdown, I assume you mean you use the "List control plugin".

    This plugin only, indeed, displays a text for a given index.

    Once you know the index, a way to associate it would be to use an array.

    When setting the name of the index in the list, you also set the value to the index in the array.

    Then, when an index is clicked in the list, you know what index to look for in the array and it will give you the IP you are looking for.

  • Yes, that was the object I was talking about.

    My doubt was because the way dropdown works in HTML.

    Anyway I solved reading the value on "selection changed" because I have all values in the AJAX.LastData.

    I'll keep in mind your suggestion if I'll need to change AJAX.LastData content.

    Thank you!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)