I dabble in Javascript for very basic tasks everyone now and then, but for the most part I'm basically a newbie. I have a page, which has multiple input elements, which all contain unique IDs, and I want to write a script that will find a collection of inputs that contain the same value, and apply a new value to all of those selected inputs. The script I have created can accomplish this by using getElementById, but this method is no good because all of my IDs are unique. I tried using getElementsByTagName('input').value, but that doesn't seem to work. The following is my code:
<input type="text" value="Original Value 1" id="input-1">
<br>
<input type="text" value="Original Value 1" id="input-2">
<br>
<input type="text" value="Original Value 2" id="input-3">
<br>
<input type="text" value="Original Value 2" id="input-4">
<script>
function change_input_value(){
var x = document.getElementById('input-1');
if(x.value = 'Original Value 1'){
x.value = 'New Value 1';
}
}
window.onload = change_input_value();
</script>