Append text to a textbox
I need to add text to a the end of a text box.
I need to add "lbs" directly after a text box to make it similiar to th "%" field.
I can easely append to the field but it gets seperated with a "<br />".
Since I need it the box and "lbs" on the same line I found a way to get around this too.
I am using this:
//Add lbs to end of field
$('.fd_field[fd_name="ALLB"]').find('br').remove();
fd.field('ALLB').control()._el().append("lbs<br />");
Is there anything more efficient or is this good enough?
Thanks.
I need to add "lbs" directly after a text box to make it similiar to th "%" field.
I can easely append to the field but it gets seperated with a "<br />".
Since I need it the box and "lbs" on the same line I found a way to get around this too.
I am using this:
//Add lbs to end of field
$('.fd_field[fd_name="ALLB"]').find('br').remove();
fd.field('ALLB').control()._el().append("lbs<br />");
Is there anything more efficient or is this good enough?
Thanks.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
What type of the field do you use? If it's a single line of text field, you'd better use the following code:
What type of the field do you use? If it's a single line of text field, you'd better use the following code:
Code: Select all
fd.field('ALLB').value(fd.field('ALLB').value() + 'lbs')
That i a neat trick to put the LBS inside the text box. I will remember that. We have picky people.
This is a single line text box in the New and Edit forms. I needed to ad the LBS to the outside of the textbox and needed it on one line but the code always inserts a <br /> after the text box then adds the "LBS" to the end of the span like so:
<div ... fd_readonly="False"><span dir="none"><input placeholder="6of9" ... type="text">
<br> <----- Goal: Remove this and insert "LBS" the proper way
</span>
lbs
<br>
</div>
When I remove the <br> I get:
<div ... fd_readonly="False"><span dir="none">
<input placeholder="6of9" name="ctl00$ctl40$g_3228d2e9_0129_43fd_8287_724b9a830616$ALLBField$ctl00$ctl00$TextField" value="300" maxlength="5" id="ctl00_ctl40_g_3228d2e9_0129_43fd_8287_724b9a830616_ALLBField_ctl00_ctl00_TextField" title="ALLB" class="ms-long ms-spellcheck-true" type="text">
</span>
lbs <----LBS outside the span
<br>
</div>
The <br> before the </span> is gone. How could I make it look like this?
<input placeholder="6of9" name="ctl00$ctl40$g_3228d2e9_0129_43fd_8287_724b9a830616$ALLBField$ctl00$ctl00$TextField" value="300" maxlength="5" id="ctl00_ctl40_g_3228d2e9_0129_43fd_8287_724b9a830616_ALLBField_ctl00_ctl00_TextField" title="ALLB" class="ms-long ms-spellcheck-true" type="text">
lbs <----Goal: LBS inside the span
</span>
<br>
</div>
I feel that my way was a hack. I am still learning and getting there little by little. Every tweak I learn is allowing me to get to the point I can easily hand it off.
Thank you for this app. Works great. SharePoint should already have this feature.
This is a single line text box in the New and Edit forms. I needed to ad the LBS to the outside of the textbox and needed it on one line but the code always inserts a <br /> after the text box then adds the "LBS" to the end of the span like so:
<div ... fd_readonly="False"><span dir="none"><input placeholder="6of9" ... type="text">
<br> <----- Goal: Remove this and insert "LBS" the proper way
</span>
lbs
<br>
</div>
When I remove the <br> I get:
<div ... fd_readonly="False"><span dir="none">
<input placeholder="6of9" name="ctl00$ctl40$g_3228d2e9_0129_43fd_8287_724b9a830616$ALLBField$ctl00$ctl00$TextField" value="300" maxlength="5" id="ctl00_ctl40_g_3228d2e9_0129_43fd_8287_724b9a830616_ALLBField_ctl00_ctl00_TextField" title="ALLB" class="ms-long ms-spellcheck-true" type="text">
</span>
lbs <----LBS outside the span
<br>
</div>
The <br> before the </span> is gone. How could I make it look like this?
<input placeholder="6of9" name="ctl00$ctl40$g_3228d2e9_0129_43fd_8287_724b9a830616$ALLBField$ctl00$ctl00$TextField" value="300" maxlength="5" id="ctl00_ctl40_g_3228d2e9_0129_43fd_8287_724b9a830616_ALLBField_ctl00_ctl00_TextField" title="ALLB" class="ms-long ms-spellcheck-true" type="text">
lbs <----Goal: LBS inside the span
</span>
<br>
</div>
I feel that my way was a hack. I am still learning and getting there little by little. Every tweak I learn is allowing me to get to the point I can easily hand it off.
Thank you for this app. Works great. SharePoint should already have this feature.
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
You can just put the field into a table and add 'LBS' text into a separate cell:

You can just put the field into a table and add 'LBS' text into a separate cell:

-
- Information
-
Who is online
Users browsing this forum: No registered users and 4 guests