Change word in given string using Jquery and enter new line in textarea
<html>
<head>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script language="JavaScript" type="text/javascript" src="http://code.jquery.com/ui/1.10.1/jquery-ui.js"></script>
<script>
var f_name='';
function fnformname(){
var from_name_val = $("#from_name").val();
if(from_name_val!=''){
if(f_name!=''){
var emailcontent_val_data = $("#emailcontent").val();
var final_data = emailcontent_val_data.split(f_name).join(from_name_val);
$("#emailcontent").val(final_data);
f_name=from_name_val;
}
else {
var emailcontent_val_data = $("#emailcontent").val();
var final_data = emailcontent_val_data.split('<fromname>').join(from_name_val); $("#emailcontent").val(final_data);
f_name=from_name_val;
}
return true;
}
}
</script>
<head>
<body>
<?php$mail_data = "Hello,\n<fromname> has sent you a link to install the app on your device."?>
<div class="fieldtext-box cf">
<div class="fieldtext alignleft">
<label for="email">From Name</label>
<input type="text" name="from_name" id="from_name" onblur="return fnformname()" />
</div>
<div class="fieldtext alignleft">
<label for="email" class="email-text-label" style="vertical-align:top">Email Text</label>
<textarea rows="5" cols="40" id="emailcontent" class="email-text" name="emailcontent" ><?php echo $mail_data;?></textarea>
</div>
</div>
</body>
</html>
No comments:
Post a Comment