Dxmxgxd
03-26-2012, 05:44 AM
Hi Guys,
I am trying to make a function that will search for a substring, in this case 'http://instagr.am/p/' within a text area on a form then add '' & '' tags around it.
I have currently got the following code
<script type='text/javascript'>
function show_alert() {
str = formname.elements['inputid'].value;
arr = (str.split(' ') + '<br />');
jQuery.each(arr, function() {
if (arr.indexOf('http://instagr.am/p/') >= 0) {
alert('An http://instagr.am/p/ link has been found');
//alert('It is entry ... in the array');
//Then edit the entry
}
}
);
}
</script>
This breaks the contents of the textarea (at spaces) into an array then finds any entries with 'http://instagr.am/p/' in them (could be 'http://instagr.am/p/29fdghHdv').
Once it has found any and all of these entries it will add an '' code to the beginning and an '' tag at the end.
Example...
http://instagr.am/p/vuHdeyfa2
is converted to:
'http://instagr.am/p/vuHdeyfa2'
Then the changes must reflected in the textarea input
"formname.elements["textareaid"].value = editedstring;
Thankyou for your assistance.
I am trying to make a function that will search for a substring, in this case 'http://instagr.am/p/' within a text area on a form then add '' & '' tags around it.
I have currently got the following code
<script type='text/javascript'>
function show_alert() {
str = formname.elements['inputid'].value;
arr = (str.split(' ') + '<br />');
jQuery.each(arr, function() {
if (arr.indexOf('http://instagr.am/p/') >= 0) {
alert('An http://instagr.am/p/ link has been found');
//alert('It is entry ... in the array');
//Then edit the entry
}
}
);
}
</script>
This breaks the contents of the textarea (at spaces) into an array then finds any entries with 'http://instagr.am/p/' in them (could be 'http://instagr.am/p/29fdghHdv').
Once it has found any and all of these entries it will add an '' code to the beginning and an '' tag at the end.
Example...
http://instagr.am/p/vuHdeyfa2
is converted to:
'http://instagr.am/p/vuHdeyfa2'
Then the changes must reflected in the textarea input
"formname.elements["textareaid"].value = editedstring;
Thankyou for your assistance.