-1

I want to display variable fullScript in the HTML below.
I tried this, but it did not work.
What am I doing wrong?

JQUERY

        $( document ).ready(function() {
            var fullDate = new Date();console.log(fullDate);
            var twoDigitMonth = fullDate.getMonth()+"";if(twoDigitMonth.length==1)  twoDigitMonth="0" +twoDigitMonth;
            var twoDigitDate = fullDate.getDate()+"";if(twoDigitDate.length==1) twoDigitDate="0" +twoDigitDate;
            var currentDate = fullDate.getFullYear() +"-"+ twoDigitMonth + "-" +  twoDigitDate;
            var currentTime = fullDate.getHours() +":"+ fullDate.getMinutes()
            console.log(currentDate);
            console.log(currentTime);


            var fullScript = "/opt/fings/interface/postEnginInstruction.py --call --viewdevicedata 130150000008 "+currentDate+" "+currentTime+" False";
            console.log(fullScript);
            $('#fullScript').html(fullScript);
        });

HTML

                <span>
                    <label for="fullScript" class="frm_label">Script to run</label>
                    <div class="frmFull"><input type="text" class="editBox readonly" id="fullScript" name="fullScript"/></div>
                </span>

PS - console.log(fullScript); is displaying 100%

1
  • This question is similar to: How to set the value of an input field element?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Dec 7, 2024 at 18:49

2 Answers 2

2

To change the value of an input, use val, not html :

$('#fullScript').val(fullScript);
Sign up to request clarification or add additional context in comments.

1 Comment

agghhh. yeah I should have known. Thanks anyway for stating the obvious. sometimes it does help
1

You should use .val() instead of .html() for setting variable to input

Change this

$('#fullScript').html(fullScript);

to

$('#fullScript').val(fullScript);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.