2

I am trying to change a textbox value. am trying following javascript but in both the alerts am getting image only. ie. $('#FileName').val = "testimage.jpg"; is not changing the text box field value.

<x:input type="textbox" id="FileName"
width="210px" value=""/>

if ($("#FileName").val() == "image") {
    alert($("#FileName").val())
    $('#FileName').val = "testimage.jpg";
    alert($("#FileName").val())
 } 

3 Answers 3

7

you have used jquery

try $('#FileName').val("testimage.jpg");

and using javascript document.getElementById('')

document.getElementById('FileName').value = "testimage.jpg";
Sign up to request clarification or add additional context in comments.

Comments

1

you should try this

if ($("#FileName").val() == "image") {
    alert($("#FileName").val())
    $('#FileName').val("testimage.jpg");
    alert($("#FileName").val())
}

Comments

0

val is a method, not a property, so:

$('#FileName').val("testimage.jpg";)

1 Comment

The question is about using javascript not jQuery.

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.