Kelly Hansen
Kelly Hansen

Reputation: 69

Update Text Box On change Javascript

Im trying to update a text box when a selection changes.

Here is the code.

<script type="text/javascript">
$("#name").change(function () {
    var selectedValue = $(this).val();
    var result = string.substring(string.lastIndexOf(":") + 1);
    document.getElementById('newname').value = result ;
});
</script>

Being an extream noob to this i dont understand why this is not working? The #name is the dropdown list "selection" and the newname is the text box i want to update.

Upvotes: 0

Views: 91

Answers (1)

deviantxdes
deviantxdes

Reputation: 479

In the var result, string.substring, do you mean selectedValue.substring ?

<script type="text/javascript">
$("#name").change(function () {
    var selectedValue = $(this).val();
    var result = selectedValue.substring(selectedValue.lastIndexOf(":") + 1);
    document.getElementById('newname').value = result ;
});
</script>

Upvotes: 1

Related Questions