Quick question - if a textfield in a webform, does not automatically has the focus set by the form, ie you got to press the field before the keyboard pops up - am I correct to assume that field cannot be edited then?
In other words - I cannot set a text for a textField by injecting javascript into it, unless it gets a focus upon loading of the website right?
NOTE: I am not talking about set texts or placeholders here:-)
Cheers
Yes you can! You can use Javascript to set the value:
[theWebView stringByEvaluatingJavaScriptFromString:#"document.getElementById('textFieldID').value = 'MyText'"]
Here's an article which shows you how to set and get the values of textfields with Javascript.
Hope this helped!
Related
I have been looking for information about this but I don't get with the solution.
I have some text fields on a page which I get updated on blur making use of jQuery events.
There's no form to submit, the update took place in the background using jQuery $.post.
If a user updates those inputs, then clicks on a link to go to another section of the page and then comes back using the browser's back button, those inputs won't show the last values set by the user but the previous ones in case there were, or empty text inputs if there weren't.
Users are reporting this as a bug (even is more a browser behavior), and I wonder if there is any solution for this.
I have been taking a look at things like this or this, but they don't solve the problem I have. I have no forms, I have no submit and I don't want to reset the form.
I've noticed this problem doesn't take place in IE 9 and either in Firefox but it does on Chrome.
The user can navigate to different pages (more than 30) with more than 12 text fields in each and therefor I have discarded the idea of storing them on sessions.
Is there any way to solve it?
Thanks.
I do not know if my solution can solve you're problem , but:
what if you bind data to you're input? e.g you can set dinamically data on input
$('input').data( 'val' , $(this).val());
and then re-bind it through
$('input').val( $(this).data() ) ;
Do not follow exactly these lines of code , I'm trying to give you an idea of what I'm wondering. I hope that it can help you.
http://api.jquery.com/data/ doc for .data()
in my web application some of screen completely deal with Js framework we are doing Automation with QTP plz help me on below issue,
Visualy weblist box if I click in that Edit box will activiate but it's completely Readonly+Non Editable if we click Dropdown Icon it will populate one window in their Tree type value(Ex:Class>>Branch>>Section) we need click Section and then press Set Button then selected values populating in the Edit box.
even though if i'm making Editbox property Readonly is false after entering the values in the edit box clicking submit button it's giving error Null value in that Edit box ?all these are developers completely written in Javascript Framework so is there way to directly entering values with out selecting Popup window values by using QTP(VBSCRIPT) or Javascript code?
Thanks
I don't exactly understand your question but it seems to me that one of the options you're asking about is how to run JavaScript code from QTP. You can do this starting with QTP11 using Page.RunScript (or Frame.RunScript).
I have a PrimeFaces (2.2.1) Editor on a page where I want to allow the user to append text to the editor by selecting a value from a drop-down list and pressing a button indicating that they want it appended to the text. I can add the text to the editor using JavaScript like this:
document.getElementById('form:editor').value = document.getElementById('form:editor').value + 'NEW TEXT!';
However, unlike an inputTextarea, the PrimeFaces Editor component doesn't refresh automatically when its value is changed. I have to press the browser's reload button or hit the editor's Show Source button to get the appended text to display. Is there anything I can do from JavaScript to get the editor to refresh itself after changing its value?
Not a good solution, but it should work.
editorWidgetVar.jqInput.var()
stores a value which would be submited on a form submit.
$(editorWidgetVar.jq.find('iframe')[0].contentDocument).find('body').html()
but this is actually visible for user element. So if you want to change content of editor, then you should change both fields (hidden for proper submitting and visible for proper display). I am almost sure there is a normal API for it. This method would be good for a temporary workaround.
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.
When I edit a resource and click on the text field in the form - the old value disappears.
it happens across multiple forms
What can cause this behavior ?
is it a rails issue or js ?
Thanks
Possibly a javascript issue - do you have a script that sets any fields deliberate to blank (like a search box, or similar)?
If so, you may have an error in it which is blanking all text boxes.
Turn off JS in your browser and try it...