jquery plugin to display a 'clear' button in a search input box - javascript

I am having trouble trying to find something I know that does exist. In some forms your can clear your textbox by clicking on a 'cross'. It looks like this
I am looking for a JQuery plugin that can add that to a textbox for me. Any help is appreciated.

Hows this for an option:
http://jsfiddle.net/ajthomascouk/hQLzX/
So basically i've enclosed the input and img inside a span, which will act as the parent.
UPDATE
I've improved my answer - http://jsfiddle.net/ajthomascouk/apgws/
Still does the same thing except now you dont have to hard code it, jQuery will do it.

Related

ngx-chips show dropdown when input is focused

I'm using ngx-chips to create a tag input for Angular 8. I got it all to work but I would like for my input to show the dropdown whenever I focus on the tag. Currently it only shows the dropdown when I focus on the input part, which is pretty small:
I want the dropdown to show when I click anywhere on the form, like this:
Is this behavior possible? I also noticed that pressing Enter can show the dropdown, but trying to trigger that behavior on click isn't really working out.
I tried altering the CSS itself by increasing the input width, but it looks and feels weird to use. So instead, I created a workaround with jQuery.
I just created a function for the component that uses ngx-chips, and used some jQuery inside that function
showDropdown() {
$('.ng2-tag-input__text-input').click();
}
Since the dropdown appears when focusing on the tag input field, what this snippet does is exactly that, but I used this function on an outer div, so that it would seem like when you click on the whole form, the dropdown would still appear.
Hope this would help someone else as well.

Ckeditor plugin functionality not working after using setData("hai");

I'm using the ck-editor(4.4.6). In Ck-editor's textarea I want to update my text, for that I use setData("hai"); that text updating correctly but some plugin functionality not working after use this setData(); (eg. restrict multiple enter if I reload the page it's working correctly).
editorInstance.setData("test text");
Anyway first time and after reload the page it working fine.
ruby on rails with jquery things are I'm using.
How can I solve this?
I don't know about ck-editor(4.4.6) but i can give you a way to solve it. You have to use based on your parent class. First time it works because it was same but after that it did't find the class/your specific term/attribute. So you have to use by calling parent class/id and under your activity.
You will need to call the update element function after setting the data, this will actually set the value in the field.
And, also you will need to specify the id of the textarea as given below.
CKEDITOR.instances.id_of_textarea.setData('hai');
CKEDITOR.instances.id_of_textarea.updateElement();
Finally, I got the answer instead of set data I just add my content to CKEditor text area as link this its working fine:
$('#cke_editor1 iframe').contents().find('body').html("Your text");

Javascript displays more text boxes depending on a pull down option?

I don't know if this is possible in Javascript but I am trying to achieve this. I don't know the terminology so I thought I would post it on here with pseudo code to help you understand what I want to implement.
Pseudo Code:
User Selects Option from pull down.
If selection matches criteria
Add text boxes to the form
Else if selection is something else
Add invisible text box with NULL value
I would like to code it myself but if you could post some reference material or links as I have not done much with Javascript.
Thanks
For your first and second entries, google for 'html select onchange'.
You'll want to check out document.createElement for "Add text boxes to the form"
To make your text box invisible, check out the CSS display property, setting it to none or block (or inline)
I've tried to keep this answer very short without code samples because it sounds like you want to do it yourself. Add a comment to my answer if you want more of an example.
EDIT
Also of note, along with document.createElement, you will want to look at appendChild to add the created element to an HTML element, most likely some FORM element in your page.

adding a text input field through js or jQuery when clicking on another input field in rails 3

I'm building a nested form in rails 3.1 and instead of pressing the "add" button i want to automaticly add an input field when typing text in an empty input field (just like making a question in facebook and adding poll options). But i also want to only add a field if there are characters typed in the field if the characters are removed the extra field should also be removed.
I am working with rails 3.1 and so jQuery and jquery-rails are included in my gem, i don't know coffee script yet.
it's really easy.
Just tap into the focus() event handler and add textboxes as you go along.
I have created a simple demo for you here: http://jsfiddle.net/mcVnN/
Warning: clicking any textbox will add a new textbox here. If you want to add new textbox ONLY on last textbox focus, just compare the id.
If you have any doubts let me know.
Cheers
--
Sorry, did not read your full question, my mistake.
I have put together some quick code http://jsfiddle.net/mcVnN/12/ again on jsfiddle, but you might want to change it to suit your needs.
I was going through my answers a now and realized I had left you in the middle of nowhere.
Took some time to completely re-write my answer - the above answer is a lot buggier, you are better off using the :last selector than manually trying to keep track of the last text box yourself.
See my rewrite here: http://jsfiddle.net/mcVnN/29/
I have also added a max text box count that you can change easily to configure how many textbox you want users to be able to add.
Please replace the above code with this one, if you are using the above one at all.
Thanks.

Validating PDF form fields before printing

I have a fillable PDF form that I would like to validate before the user prints it out.
Here is my form:
http://www.pentco.com/orderforms/pentco_creditapp_v2011b.pdf
I've looked online for a simple solution and I think I've found it. It is here:
http://www.alqemy.com/Forms/RequiredFields.pdf
I've looked at its field and button properties, but for the life of me I cannot figure out how it works. There is one line of code attached to the button behaviour and that's it.
Can someone tell me what I'm missing to put the same validation function in this form into mine?
Pete
The validateFields() method (used on button's mouse up event) is defined at document level. With Acrobat select 'Edit All JavaScripts' menu item and you will see the code for this method. It can be reused very easy, you just have to set tooltips for all required fields and these tooltips must end with '*' (this is how the method determines if a field is required).
This worked perfect...thanks for pointing out where to find that JavaScript. If others are confused:
You need to be in form edit
Then you go to Advanced-->Document Processing-->Edit All Javascript...
You will find the Validation code there. You want to copy it and add it to your print button's Javascript

Categories