How do I fix my code about a script that stopped working?

Marc

I have this code that generates an item code when the ‍combo-boxes‍‍‍ are selected.

For example, if Computer Equipment and Printer is selected, the script would generate the code ‍CEPR000001‍ and display it on the textbox. It was working last March but now it suddenly stopped working. Can someone help me with this?

Script:

function pad(num, size) {
    var s = num+"";
    while (s.length < size) s = "0" + s;
    return s;
}

function getAssetCode() {
    document.getElementById("code2").value = $('#class').find(":selected").data('value') + 1;

    var x = document.getElementById("cat").value;
    var y = document.getElementById("class").value;
    var z = document.getElementById("code2").value;         

    var result = pad(z, 6);

    var xyz = x.concat(y,result);

    $('#code').value(xyz);
}

HTML:

<select class="form-control" name="assetcategory" id="cat" required>
    <option value="CE">Computer Equipment</option>
    <option value="OP">Other Properties</option>
</select>

<select class="form-control" name="assetclass" id="class" onchange="getAssetCode()" required>
    <option value="PR" data-value="1">Printer</option>
    <option value="CP" data-value="2">Mobile Phone</option>
</select>

<input type="text" class="form-control" name="assetcode1" id="code" disabled>
<input type="text" class="form-control" name="assetcode2" id="code2" hidden>
Unbranded Manchester

Firstly you need to include jQuery in your question, not sure if this is already done but add the following line to head

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

Secondly, you need to change :

$('#code').value(xyz);

to

$('#code').val(xyz);

Working fiddle https://jsfiddle.net/fcozp36v/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

My trackpad stopped working (not detected) after update, how do I fix this?

My sound stopped working today, how can I fix it?

I tried moving my JS script into a separate js file, but it stopped working once I did. How can I fix it?

My socket app stopped working - how to fix it?

Why is this code not working, How do i fix it?

My code for this newton's cradle isn't working. How do I fix this?

Why my filters not working in the google analytics 4 app script code which I have written below? How can I fix it?

How can I fix my Binary Search code not working as expected?

how to fix my hp envy m6 that stopped working?

My IF statement is not working as it should, how do I fix this?

How do I fix my ctx not working (Discord Bot in Python)?

How do I fix my UI Buttons not working in Unity?

How do I fix movement in my pygame script?

My Julia script crashes in VS Code when I do some computations. How can I learn about the issue?

How do I fix my duplicate detection code? Java

How do i fix my code's vulnerability?

How do I fix my code for plotting a histogram?

How do I fix the indentation error in my code?

how do I fix my code in order to display one table?

How do I fix my code with Pygame to jump correctly?

How do I fix Webpack from mangling my code in production?

How do i fix my class code 'int' object error?

How do I fix my code so that it is automated?

how do i fix this subprocess error in my code

How do I fix my code for Python Mad lips loops?

How can I fix .exe stopped working error?

How do I improve my Python code about heap sort?

What can I do to fix my code with this HLSL error about array references in loops?

How do I fix Application Stopped in Android Studio?