Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Add default value to TextArea

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-04-2015, 12:29 AM
 
pyco pyco is offline
 

Member
  
Join Date: Jun 2007
Posts: 21
 

Default Add default value to TextArea

Hi,

Just a question is it possible to add feature in product_details.tpl.
When user add new product, select category A, show Text-A in description field. or when select category B, show Text-B in description field. All this happen in admin area.
Anyway to do this?
Please advice. thx
__________________
X-Cart : 4.5.2
Sunday Morning...
Reply With Quote
  #2  
Old 05-04-2015, 03:54 AM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Add default value to TextArea

Perhaps JavaScript will be the best answer. You can put an onChange or onClick event on the category select box, and then set the value of the textarea based on that.

http://www.w3schools.com/jsref/event_onchange.asp

http://stackoverflow.com/questions/415602/set-value-of-textarea-in-jquery
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #3  
Old 05-04-2015, 05:40 PM
 
pyco pyco is offline
 

Member
  
Join Date: Jun 2007
Posts: 21
 

Default Re: Add default value to TextArea

thx, I ll try it later on.
__________________
X-Cart : 4.5.2
Sunday Morning...
Reply With Quote
  #4  
Old 05-04-2015, 09:29 PM
 
pyco pyco is offline
 

Member
  
Join Date: Jun 2007
Posts: 21
 

Default Re: Add default value to TextArea

Hi,

I hav success create a html version.
<p>Select a new car from the list.</p>

<select id="mySelect" onChange="myFunction()">
<option value="Audi">Audi
<option value="BMW">BMW
<option value="Mercedes">Mercedes
<option value="Volvo">Volvo
</select>

<p>When you select a new car, a function is triggered which outputs the value of the selected car.</p>

<form name="form1" method="post" action="">
<label>aaa
<textarea name="textarea" id="textArea"></textarea>
</label>
</form>
<p id="demo"></p>

<script>
function myFunction() {
var x = document.getElementById("mySelect").value;
document.getElementById("demo").innerHTML = "You selected: " + x;

document.getElementById("textArea").value ="text " + x;
//$("textarea#ExampleMessage").val(result.exampleMes sage);
}
</script>

but how to integrate into smarty tmpl? the code are difference.
{include file="main/textarea.tpl" name="descr" cols=45 rows=8 data=$product.descr width="100%" btn_rows=4}
__________________
X-Cart : 4.5.2
Sunday Morning...
Reply With Quote
  #5  
Old 05-05-2015, 04:59 PM
  totaltec's Avatar 
totaltec totaltec is offline
 

X-Guru
  
Join Date: Jan 2007
Location: Louisville, KY USA
Posts: 5,823
 

Default Re: Add default value to TextArea

The product short decription text area in my version has an ID of "descr".

Assuming your code above is good, I think you would need:
$("#descr").val(result.exampleMes sage);

When adding javascript to smarty tmeplates, you need to wrap it with {literal}
{/literal}
tags on either side.

It might be best for you to hire a developer to do this for you, if you do not understand how to go further with these examples. It will save you time, and time is money.
__________________
Mike White - Now Accepting new clients and projects! Work with the best, get a US based development team for just $125 an hour. Call 1-502-773-6454, email mike at babymonkeystudios.com, or skype b8bym0nkey

XcartGuru
X-cart Tutorials | X-cart 5 Tutorials

Check out the responsive template for X-cart.
Reply With Quote
  #6  
Old 05-05-2015, 09:25 PM
 
pyco pyco is offline
 

Member
  
Join Date: Jun 2007
Posts: 21
 

Default Re: Add default value to TextArea

Thx Guru, I had done this and it work.
__________________
X-Cart : 4.5.2
Sunday Morning...
Reply With Quote

The following user thanks pyco for this useful post:
totaltec (05-06-2015)
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:48 PM.

   

 
X-Cart forums © 2001-2020