Hi,
I’m trying to create a function that will use values of textfields as parameters to add guide.
I can’t make it work.
this is how it looks like in html:
<sp-body>
<div style="align-content: center">
<sp-textfield placeholder="top" id="guidetop" type="number" style="width: 32%; margin-bottom: 4px"> </sp-textfield>
</div>
<sp-textfield placeholder="left" id="guideleft" type="number" style="width: 32%"> </sp-textfield>
<sp-action-button style="height: 32px" id="btncross" class="buttthird">CROSS</sp-action-button>
<sp-textfield placeholder="right" id="guideright" type="number" style="width: 32%"> </sp-textfield>
<div style="align-content: center; margin-bottom: 10px;">
<sp-textfield placeholder="bottom" id="guidebottom" type="number" style="width: 32%"> </sp-textfield>
</div>
<sp-action-button id="btnaddguides" class="buttfull">ADD GUIDES</sp-action-button>
<sp-action-button id="btnclearguides" class="buttfull">CLEAR GUIDES</sp-action-button>
<sp-radio-group id="guideselect">
<sp-radio value="percent" checked>%</sp-radio>
<sp-radio value="px">PX</sp-radio>
</sp-radio-group>
</sp-body>
and this is the function:
async function addguides() {
let topguide = document.querySelector('#guidetop').value;
let bottomguide = document.querySelector("#guidebottom").value;
let leftguide = document.querySelector("#guideleft").value;
let rightguide = document.querySelector("#guideright").value;
const batchPlay = require("photoshop").action.batchPlay;
const result = await batchPlay(
app.showAlert(leftguide)
[
{
_obj: "make",
new: {
_obj: "good",
position: {
_unit: "percentUnit",
_value: leftguide
},
orientation: {
_enum: "orientation",
_value: "vertical"
},
kind: {
_enum: "kind",
_value: "document"
},
_target: [
{
_ref: "document",
_id: 532
},
{
_ref: "good",
_index: 4
}
]
},
_target: [
{
_ref: "good"
}
],
guideTarget: {
_enum: "guideTarget",
_value: "guideTargetCanvas"
},
guideUserValue: {
_unit: "percentUnit",
_value: leftguide
},
_options: {
dialogOptions: "dontDisplay"
}
}
],{
synchronousExecution: false,
modalBehavior: "fail"
});
}
document.getElementById("btnaddguides").addEventListener("click", addguides);
When I use _value: 30 it works perfectly but somehow if I use variable ( _value: leftguide ) it doesn’t work.
I’ve tried everything. I would really appreciate your help.
Thank you!