Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PS Panel: How can execute actions from a Select box (dropdown menu)?

New Here ,
Aug 12, 2015 Aug 12, 2015

I need some help with this. Want to create a Photoshop Panel with a Dropdown menu wich is just a Select Box with different options,

each option must to execute an action. Couldn't found examples, an starting point. I know the basics, how to export the actions to Js, but

what to use to link those options from the html to the jsx file?


Eg:

<select>

<option selected>Action 1</option>

<option>Action 2</option>

<option>Action 3</option>

</select>

Thank you.

TOPICS
Actions and scripting
536
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Expert ,
Aug 12, 2015 Aug 12, 2015

Hi,

see this for an example using jQuery:

http://stackoverflow.com/questions/11179406/jquery-get-value-of-select-onchange

Then you can use the function to call some JSX:

$('select').on('change', function() {  

    evalScript('yourJSXFunction("' + this.value + '")') // just an example

});

Hope this helps,

Davide Barranca

---

www.davidebarranca.com

www.cs-extensions.com

Davide Barranca - PS developer and author
www.ps-scripting.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 12, 2015 Sep 12, 2015
LATEST

Many thanks,

I was trying to make it work without much luck.
I've tried too many ways and the most closer is this:

HTML

<select onchange="getval(this);">
   <option selected>CHOOSE ACTION</option>
   <option value="DoAction1">Action 1</option>
   <option value="DoAction2">Action 2</option>

    </select>

JS

var csInterface = new CSInterface();

function init() {

themeManager.init();

$('select').on('change', function() {  csInterface.evalScript( this.value() ); });

That does NOT work, but changing it for this it works fine (only with that particular action 1):

$('select').on('change', function() {  csInterface.evalScript('DoAction1()'); });

_____________________________

So, I know that the onchange is working, but I don't know why using (this.value()) isn't working, it just does nothing.


Thanks in advance!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 13, 2015 Aug 13, 2015

You can try this without jQuery:

HTML

<select id="MyActions" size="1">

     <option value="Action1">Action 1</option>

     <option value="Action2">Action 2</option>

</select>

JS

var csi = new CSInterface(),

    selectedAction = window.document.getElementById("MyActions").value;


csi.evalScript('startScript("'+selectedAction+'")');

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines