Substr in Auto-texts

Hello there!

Today lets talk about how to create a substr in auto-texts.

You just have to:

1. Create a new document;

2. Create an HTML Container;

3. Insert this code:

<script type=”text/javascript”>

function substringFunc(){
var username= document.getElementById(“pText”).innerHTML;
document.getElementById(“pText”).innerHTML = username.substr(1,5);
}
</script>
<p id=”pText”>{&USER}</p>

<script>

document.getElementById(“pText”).onload= substringFunc();
</script>

4. Change the substr values to get what you need for your string. Here is an explanation of this javascript function: http://www.w3schools.com/jsref/jsref_substr.asp

You can also change the {&USER} to another auto-text.

Run your document in Express or Interactive mode and you will get something like that:

pic

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s