I have a page where you enter customer-id first and hit submit. That point it will validate the customer and if valid, comes back to the same page to enter quote number. Initially quotenumber field will be grayed out and can not be edited. My question is, after it comes back to the page, I need the cursor to go to the "quote number" text box instead of customer-id text box (currently it goes to customer-id text box). How can I solve this?
use javascript's focus() function or jQuery
in jquery it would be
$("#myinput").focus();
Related
I'm creating a program in vb.net to go to https://www.royalmail.com/track-your-item#/ and:
Enter some text in the Reference Number box
Click the button 'Track your delivery'
Grab the text from the page so I can search for the delivery date
I've had to switch to using CeFSharp, as the microsoft browser doesn't want to load the page, so this is my first time with it.
This is what I have so far (CWB1 is the name of the browser object):
CWB1.LoadUrl("https://www.royalmail.com/track-your-item#")
CWB1.LoadUrl("javascript:void( document.getElementById( 'barcode-input' ).value='12345678' )")
Dim script = "var pagebutton = document.getElementById('submit');
pagebutton.click();"
CWB1.ExecuteScriptAsyncWhenPageLoaded(script)
The page loads, the text '12345678' is entered in the search box, but running the script to press the button does nothing.
I can't figure out how to press the button. I thought it must be the wrong id, but inspecting the web page seems to give button id="submit" so this should work? I've tried a few variations but nothing seems to move me forwards.
I also then need to grab the text from the page - not sure how to so this either?
Thanks for any help!
OK, I've found that the button press only works if you enter the text in the field via sendkey event. So the button press code was working after all - I guess the site's security is trying to make sure someone is typing the text in, instead of a robot. Thanks for your help with this amaitland!
document.getElementById("hs-search-origin").value = myloc;
I am successfully writing the value in a Text Box
The text box is attached to a searchbox and up on clicking the search button, search is not happening.
I have to edit the textbox, like remove character or add character in the text box, to make it work.
For Ex:
myloc="i love stackoverflow";
document.getElementById("hs-search-origin").value = myloc;
The text box shows the value i.e "i love stackoverflow" but on clicking the button, nothing happens.
I have to either edit the text in the textbox and then click on search to make it work. What is the issue, any guess
You have some code which runs (and does a search) when the user changes the value of the text box.
It doesn't run when you change the value with JavaScript.
You need to call that code explicitly when you want it to fire in response to something else than the user typing.
The idea is that I have two text fields and after I move from one field to another field the page refresh is done and there is no focus afterwards on the second field. I need to put cursor to the second field where it was previously before page update. Can somebody please tell me how to fix this issue? Thank you in advance.
if($('#textbox1').val()) {
$('#textbox2').focus();
}
You can do something like this, but need to take care of edit case (if any), so the condition can be anything as per your needs.
Check the empty field in document.ready and focus on it with .focus().
After filling your first field check both fields and focus on empty one.So on first page load it will focus on your first field and after second load it will focus on you second field.
I need to implement a code in jquery, where I can enter any text in the text field, and then after I click on the "Submit" button, that text should turn into a clearable field something like this
I tried putting this box in my textfield, but this makes my whole text field as a clearable field,
$(document).ready(function(){
$('input[type=text]').clearableTextField();
});
I dont want to do this, I want that when i type something in the text field and click the Submit button, it should become a clearable text object.
Any help is appreciated!
Thanks.
One way to achieve this (similar to the way tag entry is done on Stack Overflow) is to have a separate div to the left of your input field into which "clearable text fields" are placed. When the submit button is clicked (or the spacebar is hit, or any trigger that javascript can listen for), have javascript create a new span within the left div, and reduce the width of the input field by the same width as the new span tag. You can include a delete button and any relevant styling in the HTML/CSS for the span.
A demo which achieves a similar effect through jQuery is available here: http://xoxco.com/projects/code/tagsinput/. (Suggested by #sachleen in response to a similar question)
I don't know what this is called so its hard to google for it.
If you have a plain html input type=text with a small width eg 20 and then type more characters than can be displayed, it shows the last characters you type. And the first ones are scrolled out of view:
This is my long text // this is the whole string
my long string // this is what is actually visible in the input box
How do I make it so that when you hit tab, the view area resets so that the start of the string is visible and the end is hidden?
my long string // this is what is visible in the input box when typing
This is my // this is what is I want to be visible in the input box after you hit tab
What do you call this, and how do you do it?
I don't know if your question has been answered, but I just felt like answering myself. You can do it by using ranges and window selection. Here, I made a JSFiddle for you.
$(document).ready(function(){
$("input").bind("keyup",function(e){
if(e.keyCode==9){
var r=document.createRange(),
gs=getSelection();
r.setStart(this,0);r.setEnd(this,0);
gs.removeAllRanges();gs.addRange(r);
}
});
$("input").bind("blur"),function(){
$(this).focus();
});
});