0

I've tried figuring this out, but still having some trouble.

I want to set the text (e.g. Name) of an Input Box in a Dialog form from inside the script because the text will be determined at run time. I don't know it at design time. I have learned that the text comes from:

<div id="dialog-form" title="Create new user">
    <p class="validateTips">All form fields are required.</p>
    <form>
        <fieldset>
            <label for="name">Name</label>
            <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
        </fieldset>
    </form>
</div>

From the ... label for="name">Name.. to be specific.

The form is actuallyderived from the JQuery UI standard example:

http://jqueryui.com/dialog/#modal-form

My questions are:

Can I avoid this way to set the text at all? Can I set it entirely via the script?

If not, how can I change it via the script?

If not, how can I access the text "Name" in the html and change it from the script?

1 Answer 1

2
    <fieldset>
        <label for="name">Name</label>
        <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
    </fieldset>

<script>
var text = $('#name').prev().text(); // get the text

$('#name').prev().text('YourTextHere'); // Change the text
</script>
Sign up to request clarification or add additional context in comments.

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.