Reputation: 129
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?
Upvotes: 0
Views: 3890
Reputation: 17104
<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>
Upvotes: 2