• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 691
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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