• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

jquery editInPlace select_options shows repeats if I put the default value first

jquery editInPlace select_options shows repeats if I put the default value first


if $yesOrNo='yes' then
select_options=
yes
yes
no

if $yesOrNo='no' then
select_options=
no
yes
no


$savingText="saving....";
$selectOptions="yes:yes ,no:no";
        echo '<h3>Value:<span id="yesOrNo">'.$yesOrNo.'</span></h3>';
        echo '<script type="text/javascript">
                    $(document).ready(function(){
                        $("#yesOrNo").editInPlace({
                            saving_text: "'.$savingText.'",
                            field_type: "select",
                            select_options: "'.$selectOptions.'"
                        });
                    });
                </script>';

Open in new window



without doing
if $yesOrNo='yes'
selectOptions="no:no"
else
selectOptions="yes:yes"

is there a way to eliminate repeats
0
rgb192
Asked:
rgb192
1 Solution
 
hieloCommented:
You need a callback option that returns the selected value:
$savingText="saving....";
$selectOptions="yes,no";
        echo '<h3>Value:<span id="yesOrNo">'.$yesOrNo.'</span></h3>';
        echo '<script type="text/javascript">
                    $(document).ready(function(){
                        $("#yesOrNo").editInPlace({
                            "saving_text": "'.$savingText.'",
                            "field_type": "select",
                            "select_options": "'.$selectOptions.'"
                            ,"callback": function(element_id, selectedValue, originalText) { 
								return selectedValue;
							}
                        });
                    });
                </script>';

Open in new window

0
 
rgb192Author Commented:
thank you
your solution works

I have a question if the form is processed on another page
(callback wont work)

http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_27857699.html
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now