i would love to have the textbox value as my radio button value. For example, if I type "1" in the textbox, then the radio button value would change to "1".I hope i could find answers here. By the way, i am using Joomla, and if there are javascripts, pls tell me where to paste it. thanks so much!!!
Never mind, i solved it :D
here it is.
$('#textbox').keyup(function(event){
var value = $(this).val();
$('#radio').val(value);
});
you also need to change the value of your #radio to the id of your textbox e.g
Related
I want to have a textbox with a hint. For example, if that textbox triggers a search, I want it to initially have a "Search" text greyed out and when the user starts typing for it to disappear. How do I achieve this in ZK?
In android I think I had the hint tag, so I want something similar to that.
Okay, so I found it's called placeholder.
If I have an <input> of type submit, with a name, I can catch that name in my MVC model when I use it to post. Is the same not possible with a <button>, of type submit and the same name?
If I use for example name="ButtonName", my property ButtonName get's the input's value. For some reason this doesn't work with a button element.
The reason I want to use a button instead of input, is that i need to have more than text inside the button (including a picture).
You could set the value of the hidden input by using a simple onclick Javascript function for each of your inputs.
function setHidden(sender){
document.getElementById("hidden1").value = sender.value;
}
I have this case where I set a current item from a list and I need to use a textarea to edit that element's value.
Because of some constraints I have to use a keyup event but I don't think that's a problem.
Check this fiddle: http://jsfiddle.net/terebentina/Euj2C/
click on first/second buttons - it works, it changes the text in the textarea to the value of each element.
change the text in the textarea to something
click on the first/second buttons again - the textarea is not updated anymore. If you look in console, you can see that it switches between the elements, it's just that the textarea is not updated anymore.
Any suggestions? this is driving me nuts!
I know there is a better way modifying your directive to do this but as a quick fix for now you can try binding your textarea to a ngModel value that is just a copy of the current text in the selected element:
<textarea keyup="" ng-model="keyupText"></textarea>
With this in as your current function:
$scope.current = function(idx) {
$scope.current_element = $scope.elements[idx];
$scope.keyupText = $scope.current_element.value;
console.log('current is', $scope.current_element.value);
}
See this fiddle for an example.
I have a simple datepicker I'm using on a couple of date inputs. Here's the code:
$('input.isDate').datepicker({
numberOfMonths: 1,
onSelect: function () {
$(this).removeClass('placeholder'); //default is to keep placeholder style format
},
onClose: function () {
$(this).focus(); //otherwise focus goes to neverneverland
}
});
Datepicker shows on focus. The two .isDate inputs have a placeholder value of "Date".
The problem arises if the user presses the escape key when in the datepicker. The intended behavior of this is to close the datepicker and restore whatever text was in the box at point of entry. In my case the input box's value becomes the placeholder value. Leaving the box at this point leaves the word "Date" in the box as a hard value rather than as a placeholder prompt, so it trips some field-level date validation that I have.
I've been able to deal with that by blanking the text value when the user leaves the box, but the user oughtn't to have to erase that text when he escapes out of the datepicker to enter a date manually. I've made numerous attempts to use events to get rid of this, and none of them work: I've tried focusin, trapping esc in keypress, and the create, beforeDisplay, onSelect and onClose events of the datepicker itself. In all these cases, the value of the box was still "". Clearly, the datepicker sets the value of the box after finishing all of its business, and I'm thinking that placeholder wasn't taken into account in this design. Possibly a bug? We're using the Whitelabel skin, so maybe they are interfering with the datepicker in some way? Anyway, I'd much appreciate a workaround or an explanation. I haven't been able to find much of either.
TIA
Without knowing more about your application, I think you'd be better off using a good label and leaving the input blank. There is also an actual placeholder feature in "HTML5".
I want to make text area, where always is pre written text, and that piece of text is located at the end, and it wouldn't be possible to delete. For example, you write answer here, and at the end, right side of cursor, is text "This is end of my answer".
And when you POST it, it displays your written text and "This is end of my answer" at the end.
I know, that I can attach this text easily after posting it, but it must be displayed, and anyone could see it.
I need javascript/jQuery solution.
Thanks!
The text to the right side of the cursor, that moves as you type is really annoying and zero-usable. However, if you want something like that I would suggest putting a background image on the textarea with the text you want. It will be static and none will be able to edit it, and at the same time will always see it.
<input class="myinput" name="myinput" type="text" value="Text_Ends_Here" /></input>
$("input[name=myinput]").click(function()
{
var currentValue = $(this).val();
currentValue = currentValue.replace("Text_Ends_Here", "");
$(this).val(currentValue);
}
);
$("input[name=myinput]").focusout(function()
{
var currentValue = $(this).val();
$(this).val(currentValue + ' Text_Ends_Here');
}
);
http://jsfiddle.net/gXvLB/95/
You can position the required text over textarea using positioning.