How do I Use option value in construct 2

Get help using Construct 2

Post » Thu Nov 17, 2016 3:11 pm

In html I can make a dropdown like this:

Code: Select all
<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>


In construct 2 it seems to me that I only have a text for the option.... something like:
Code: Select all
<option>Volvo XC90</option>

and I can't find a way to show text and send a different value.
Is this missing?
Tank you!
B
12
S
5
Posts: 42
Reputation: 990

Post » Thu Nov 17, 2016 8:44 pm

What are you trying to do?
B
45
S
15
G
73
Posts: 2,006
Reputation: 43,394

Post » Fri Nov 18, 2016 1:16 pm

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:
Code: Select all
tokenat(AJAX.LastData,(ServerList.SelectedIndex*2)-1,"|")
to get the ip associated to the selected server
B
12
S
5
Posts: 42
Reputation: 990

Post » Fri Nov 18, 2016 2:25 pm

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.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
284
S
109
G
91
Posts: 7,317
Reputation: 87,483

Post » Sun Nov 20, 2016 7:04 pm

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!
B
12
S
5
Posts: 42
Reputation: 990


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests