Re: [Cppcms-users] get selected value of cppcms::widgets::select
Brought to you by:
artyom-beilis
|
From: Lee E. <le...@el...> - 2013-06-25 21:16:31
|
the select widget has two methods you may be interested in: http://cppcms.com/cppcms_ref/latest/classcppcms_1_1widgets_1_1select__base.html#ad1a5e79b6f21a0660d0767030a294697 http://cppcms.com/cppcms_ref/latest/classcppcms_1_1widgets_1_1select__base.html#ad59c85ad04ffb550579ea4feef9e28d8 those give you either the index of the selected item - or its id string (the "2" in your case) there is no API to get back from the id to the message you set for the options (the "two") (and as i wrote - that information is NEVER sent from the client back to the server anyhow) but since you built it - you can get to it from the id value you can get too - or change the id value to be the same as the message value (both are strings anyhow) On Tue, Jun 25, 2013 at 2:41 PM, ccppprogrammer <ccp...@gm...>wrote: > Data already exists on server (array with data which I filled select html > element), e.g. > cppcms::widgets::select select; > select.add("one", "1"); > select.add("two", "2"); > select.add("three", "3"); > > So we just need to take selected key (value="x") from POST and get value > from array of data by the key. > > > > On Wed, Jun 19, 2013 at 7:42 AM, Lee Elenbaas <le...@el...> wrote: > >> you have a problem with your HTML >> >> since your option is like this: <option value="2">two</option> >> the text "two" is used as label - and the browser will NOT send it back >> to the server, insead it will send the value "2" >> >> if you want the value sent from the server to be something else - place >> whatever you want on the value attribute of the option >> >> >> On Tue, Jun 11, 2013 at 7:52 PM, ccppprogrammer <ccp...@gm... >> > wrote: >> >>> ... small typo in sample html element: >>> <select name="test"> >>> <option value="1">one</option> >>> <option value="2" selected>two</option> >>> </select> >>> >>> So I need method to get value "two" from test widget. >>> >>> >>> On Tue, Jun 11, 2013 at 8:28 PM, ccppprogrammer < >>> ccp...@gm...> wrote: >>> >>>> Dear All! >>>> >>>> I didn't find method to get selected value of cppcms::widgets::select. >>>> I need method to get value "two" from test widget. >>>> Unfortunately selected() method returns integer index of the list not >>>> value. >>>> >>>> http://cppcms.com/cppcms_ref/1.0.2/classcppcms_1_1widgets_1_1select__base.html >>>> >>>> <select name="test"> >>>> <option value="one">1</option> >>>> <option value="two" selected>2</option> >>>> </select> >>>> >>>> Thanks in advance! >>>> >>>> >>> >>> >>> ------------------------------------------------------------------------------ >>> This SF.net email is sponsored by Windows: >>> >>> Build for Windows Store. >>> >>> http://p.sf.net/sfu/windows-dev2dev >>> _______________________________________________ >>> Cppcms-users mailing list >>> Cpp...@li... >>> https://lists.sourceforge.net/lists/listinfo/cppcms-users >>> >>> >> >> >> ------------------------------------------------------------------------------ >> This SF.net email is sponsored by Windows: >> >> Build for Windows Store. >> >> http://p.sf.net/sfu/windows-dev2dev >> _______________________________________________ >> Cppcms-users mailing list >> Cpp...@li... >> https://lists.sourceforge.net/lists/listinfo/cppcms-users >> >> > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev > _______________________________________________ > Cppcms-users mailing list > Cpp...@li... > https://lists.sourceforge.net/lists/listinfo/cppcms-users > > |