Adjust attribute of html textarea dynamically? - html

I have the following textarea:
<textarea id="edit-note-text" autocorrect="on"><%= text %></textarea>
While this text area is in use or, in other words, while someone is typing, I need to dynamically set the autocorrect attribute to off and back to on:
<textarea id="edit-note-text" autocorrect="off"><%= text %></textarea>
Unfortunately this doesn't seem to work:
document.getElementById(‘textarea’).setAttribute(‘autocorrect’, ‘off’);
I'm in a iOS UIWebView and could try to do this natively if possible as well but this is what comes to mind first. Is this possible?

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script>
//Declare functions
function taFocus(element){ element.setAttribute("autocorrect", "off")}
function taBlur(element){ element.setAttribute("autocorrect", "on")}
</script>
</head>
<body>
<textarea id="edit-note-text" autocorrect="on" onfocus="taFocus(this);" onblur="taBlur(this);" >texto</textarea>
<textarea id="edit-note-text2" autocorrect="on">texto</textarea>
</body>
</html>
Some like this maybe that you need

Related

input type tag missing in browser when tested through wordpress

I've started coding html in wordpress. I have a html code with label tag and an input tag of type "text". The input field is not getting displayed in browser. The same code works fine in eclipse. What might be the problem. When I save the post as draft the tag disappears. Not able to solve the issue. Kindly help me in this regard.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Hello testing</title>
</head>
<body>
<div> <label> Name:</label> <input type="text"> </div>
</body>
</html>
Above image is the code run through eclipse
Above one is the image run through wordpress preview
when writing html in the Wordpress editor, you can only use tags that are allowed by Wordpress. Dont think the input tag is one if them.
Look at this:
https://en.support.wordpress.com/code/#html-tags
The "input" tag is not supported by WordPress editor.

Several Links to the Same URL

I have an HTML file that has several links to the same URL. Is there a way to specify the URL once, instead of in each anchor? Currently, if I change the URL, I manually change it in each anchor. I would consider a Javascript solution, but would prefer something a bit simpler and lightweight. Here is a code sample with two links to google.com:
<HTML>
<HEAD>
</HEAD>
<BODY>
<P>
Preferred search engine
</P>
<HR>
<P>
Google
</P>
</BODY>
</HTML>
You can use the <base> element:
For example:
<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled 1</title>
<base href="https://www.google.com/">
</head>
<body>
<p>
Preferred search engine
</p>
Google
</p>
</body>
</html>
Any links you specicfy will be relative to the base URL, so if you had Preferred search engine the link would be https://www.google.com/foo.html
You have to use javascript to do that. jQuery will do nicely:
$(function() {
$('a').attr('href','https://www.google.com');
});
Then you can call the same thing if the URL changed.
If you don't want to use jQuery this is the equivalent js code:
<script>
function ChangeHref(){
document.getElementById("a").setAttribute("onclick", "location.href='https://www.google.com'");
}
</script>
You cal trigger the changehref from anywhere you want.
BTW: the above function is equal to document.ready.

Eclipse HTML: placeholder is not an attribute?

I am using the latest version of Eclipse Luna (for Java EE developers), and when I insert an <input type='text' placeholder='test123', eclipse says "Undefined attribute name (placeholder).".
Why is it like that? Have I done something wrong? Is there a way of fixing this?
Add the <!DOCTYPE html> indicating that its HTML5, placeholder is a new element in HTML5 and doesn't exists on HTML4 or early versions
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form>
<input placeholder="aspdkpoas"/>
</form>
</body>
</html>
Eclipse checks for html tags and attributes against the doctype. Make sure that you have given doctype on top. It will fix the problem.
Also, Eclipse uses IE internally. You can configure it to firefox/chrome for better tags and attribute comparison.
Refer to this How can I change eclipse's Internal Browser from IE to Firefox on Windows XP? for changing your browser.

Can't get TinyMCE 4.0.6 to work

This is driving me crazy....
I'm trying to get TinyMCE v4.0.6 to work, and I'm probably doing something very dumb, since I can't get the editor to display at all.
I could get a v3.5.8 editor to show in a page similar to what follows, but no joy with this:
<!DOCTYPE html>
<html>
<head>
<title>TinyMCE Test</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<script type="text/javascript" src="tinymce/tinymce.min.js"></script>
<script type="text/javascript">
tinymce.init({
selector: "textarea"
});
</script>
</head>
<body>
<form method="post" action="something">
<textarea name="content" cols="100" rows="15">content</textarea>
<input type="submit" value="Save" />
</form>
</body>
</html>
I've verified (using FireBug) that the path to the tinymce JavaScript file is correct, but other than that, I'm completely at a loss.
Thanks for any suggestions..
After your comment, I took your HTML and checked it with a CDN copy of tinyMCE and it work fine: http://codepen.io/anon/pen/mIvFg so I can only assume it's an error with your tinymce.min.js file.

How to force to display a number with a comma with input type number?

I have this input type number:
<input type="number">
Of course the value is a number, how to force it to display a number with a comma? And make it compatible with most HTML 5 browsers?
I searched but I didn't find a solution. I outputted a number but it is not showing with a comma.
You can use the french locale lang="fr" that use a comma for the decimal separator.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Input test</title>
<script>
function init(){
document.getElementById('in1').value = 3.14;
}
</script>
</head>
<body onload="init()">
<input id="in1" lang="fr" type="number">
</body>
</html>
It works well with Firefox 39.0:
but unfortunately it's not yet implemented in Chrome 44.