Can't you make the dropdown and button (though switch it to an input
type=button) and wrap them both in a form. Then you don't need to do any
onclick and JavaScript stuff.

Otherwise you want document.queryElement("some selector that targets your
button").addEventListener("click"...)

On Tue., Jun. 21, 2022, 10:44 p.m. Nozim Islamov, <
mukhammadnozim.isla...@gmail.com> wrote:

> Greetings everyone,
> I want to create a button where whenever it clicks it takes the value of
> dropdown that I have and set it as <h1> on the same page, can anyone help
> with this one?
> Action class code:
>
> package io.jenkins.plugins.sample;
>
> import hudson.model.Run;
> import hudson.util.ListBoxModel;
> import jenkins.model.RunAction2;
> import org.kohsuke.stapler.DataBoundConstructor;
> import org.kohsuke.stapler.DataBoundSetter;
>
> public class PipelinePromotionAction implements RunAction2 {
>
> private transient Run r;
> private String status;
>
> @DataBoundConstructor
> public PipelinePromotionAction(String status) {
> this.status = status;
> }
>
> public String getStatus() {
> return status;
> }
>
> @DataBoundSetter
> public void setStatus(String status) {
> this.status = status;
> }
>
> @Override
> public void onAttached(Run<?, ?> r) {
> this.r = r;
> }
>
> @Override
> public void onLoad(Run<?, ?> r) {
> this.r = r;
> }
>
> public Run getR() {
> return r;
> }
>
> @Override
> public String getIconFileName() {
> return "star.png";
> }
>
> @Override
> public String getDisplayName() {
> return "Manual Promotion";
> }
>
> @Override
> public String getUrlName() {
> return "promotion";
> }
> }
>
> And here is the jelly code:
>
> <?jelly escape-by-default='true'?>
> <j:jelly xmlns:j="jelly:core" xmlns:l="/lib/layout"
> xmlns:st="jelly:stapler" xmlns:f="/lib/form">
> <l:layout title="Promotions tab">
> <l:side-panel>
> <st:include page="sidepanel.jelly" it="${it.r}" optional="true" />
> </l:side-panel>
> <l:main-panel>
> <h1 id="header_status">
> Status: ${it.status}
> </h1>
> <div>
> <f:entry title="Choose promotion status" field="status">
> <select name="status">
> <option value="promoted">Promoted</option>
> <option value="not_promoted">Not promoted</option>
> </select>
> </f:entry>
> <button>Click me</button>
> </div>
> </l:main-panel>
> </l:layout>
> </j:jelly>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jenkinsci-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jenkinsci-dev/ef12d8a7-b242-413f-90b8-6148f150f343n%40googlegroups.com
> <https://groups.google.com/d/msgid/jenkinsci-dev/ef12d8a7-b242-413f-90b8-6148f150f343n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-dev/CAG%3D_Duv9adDpg5oxBPxvHQv1EdoSXS0whwtP%3DPfLNX3WhdVgzw%40mail.gmail.com.

Reply via email to