Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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+'")');