Pop-up Modal Text field - javascript

I'm looking for a script that will fire up whenever I click on an input box there will be a pop up modal with TextField and save and cancel button. So when I click save the text i typed on the text field will be saved on the input box.
I'm so sorry been busy with something else and I'm so sorry for being not so descriptive with my question (just a newbie). I'm currently using this: mywebdeveloperblog.com/my-jquery-plugins/jquery-popbox my only problem is that there's no 'cancel' button so there's no way to cancel in iOS or other touch devices. Can anyone help? Thanks.

Search for jquery ('#seuID').onclick() function with a alert inside the function it will call and pass the result into a variable or array so you can do what you want with it.

Try
$('input[type="text"]').focus(function(){
//your code here
});
you can find more info here.

$(document)
.ready(function () {
$('input')
.click(
function () {
var NWin = window.open($(this)
.prop('href'), '', 'height=800,width=800');
if (window.focus) {
NWin.focus();
}
return false;
})
});

Related

Select text in input field

I am going in circles here. Thought I could fix this issue asked a question earlier answered it only to get stuck again. Have a simple form with multiple panels containing text and numeric input field. When a user clicks in tabs in or whatever the content of that input field text should be selected. I've started looking at THIS article and also looking at the jquery focus and select. Nothing seems to be working. When clicking in the input field nothing seems to be highlighting the text already there.
Thanks
Here are a few things I've tried :
$("input[type=text]").focus(function() {
$(this).select();
});
$('#itemPanel :input[type="text"]').each(function() {
$(this).click(function() {
console.log("I was clicked in");
});
});
How about using on focus
$('input[type=text]').on('focus', function() {
$(this).select();
});
You can also use mouseup
$('input[type=text]').on('mouseup', function() {
$(this).select();
});
Fiddle
To autoselect the text in the input box I would recommend using clickevent instead of the focus event in your example.
This also seems to be written in the code example link you posted. http://www.electrictoolbox.com/jquery-select-function/ (Notice how it's using click instead of focus)
Try this:
$("input[type=text]").click(function() {
$(this).select();
});
--EDIT
Based on some feedback in the comments, there's a link to another similar question that suggests something like this:
$('input[type=text]').focus(function() {
$('input[type=text]').select().one('mouseup', function(e) {
e.preventDefault();
});
});

Cannot get enter keypress to work in jQuery when calling click function

I'm currently working on code that builds a div box when the user clicks on the .pTile div that does not have the .join class. The click function works, however, for accessibility reasons, I need to have the enter key also build the div when the user uses the enter key. There are multiple .pTile's on the page and more or less can be added at any time through a database. I can't seem to get the enter key function to work. Assistance would be much appreciated.
The following is the working click function the code in it is omitted as it's pretty long:
$(document).on('click', '.pTile:not(.join)', function (e) {
//Do stuff
});
This is the code that I am not able to get to work:
$('.pTile:not(.join)').bind('keypress', function (e) {
if (e.keyCode || e.which) {
$('.pTile:not(.join)').click();
return false; }
});
EDIT: I'd also like to note that the key press function does not get fired at all.
Here is a JSBin with a solution: http://jsbin.com/yelomunafo/1/
Basically you add keypress to the $(document).on('click') part.

Get info from textbox without submit button in JavaScript?

How can I do this? I basically want to call a function where I get the info from the textbox once the user is done entering info. I.e., after they click off of the text box. I couldn't find the clear way to do this. Is there an API for event/actions and what you can do on each input?
Try the blur event:
yourTextBox.onblur = function() {
console.log(yourTextBox.value);
};
or
yourTextBox.addEventListener('blur', function() {
console.log(yourTextBox.value);
});
See the documentation for the blur event on MDN here.

fire jquery focus out when only the input focus is changed

I use the following code to add the selected div value into a input.
var lastFocus;
$('.num-button').click(function(e){
e.preventDefault();
e.stopPropagation();
//addOrRemoveWatermark(lastFocus);
$(lastFocus).val($(lastFocus).val() + $(this).children('span').html());
});
$('.del').click(function(e){
e.preventDefault();
e.stopPropagation();
//addOrRemoveWatermark(lastFocus);
$(lastFocus).val(function(index, text){
return text.replace(/(\s+)?.$/, '');
});
})
below is a sample image if the input panel I have! This is developed for a touch device and hence the key pad.
The script works fine to add value on each button press in the keypad. The problem I'm facing is for the room number I want to run an ajax call after the user has entered the amount. But since the focus is removed every button click, how can I run the script when the focus is changed to another input. I tried the jquery .focusout() method but it gets fired each and every time the user clicks on a number button.
if anyone can suggest me a work around that would be a great help!
thank you!
Perhaps you could delay the request with something like the following:
var roomNoChanged = false;
$('#room-number').change(function() {
roomNoChanged = true;
});
$('#table-number, #no-of-guests').focus(function() {
if(roomNoChanged) {
roomNoChanged = false;
$.post(...)
}
});

How do I add an onclick event to the OK button of the Javascript confirm box?

I am working with a .Net 1.1 web application. There is a Save button that, when clicked, will pop up the Javascript confirm box. Once the user clicks OK a long running process is kicked off. We would like to show a busy indicator when the user clicks the OK button of the confirm dialog. Can this be done?
if(confirm("Are you sure you would like to save?")){
alert("Loading") //Replace with what you want to do
}
The button on an alert() dialog is not scriptable. You need to find where in the code the alert() is called and patch in to the code just after this.
What you want to do is pretty simple. A confirm('Text') returns true or false after the user makes their selection. All you need to do is on true show a busy indication.
Here is what you're looking for http://jsfiddle.net/Akkuma/C6ZZf/
$('#save').on('click', function () {
var shouldSave = confirm('Make your choice');
if(shouldSave) {
alert('Do saving');
}
else {
alert('Not saving');
}
});

Categories

Resources