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

Can anyone help in simple Javascript

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 02-17-2014, 08:28 AM
  Petepots's Avatar 
Petepots Petepots is offline
 

eXpert
  
Join Date: Aug 2007
Location: Surrey, UK
Posts: 275
 

Default Can anyone help in simple Javascript

I want to change

product_details.tpl

to display the content something like this, product details below all the code would be held in the Detailed description: and where the (see more) bit is would call the labels for the extra text that's required.
-------------------------------------------------------------
Sample full description

We make blah blah blah
This product is a wonderful unit. It works very well see more...
The range of colours you can get see more...
you can get this from the uK see more...
---------------------------------------------------------------

Now where the see more... bit is would be Javascript. I want it to work just like the admin maintenance ( see sample below) but all it has to do is just add more text.

Check database integrity http://localhost/store/skin/common_files/images/spacer.gif
This tool allows you to improve the consistency and quality of data structures in your MySQL database. more...

My product details has HTML in it and works well


I hope I have made myself clear. Can anyone help

Peter
__________________
Version 4.7.2
Reply With Quote
  #2  
Old 02-19-2014, 04:50 PM
  cherie's Avatar 
cherie cherie is online now
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Can anyone help in simple Javascript

Untested but this might at least point you in the right direction.

HTML Code:
<a href="#" onclick="toggle('moreDescr');return false">see more</a> <div id="moreDescr" style="display:none"> {$product.descr} </div>
PHP Code:
{literal}
<
script type="text/javascript">
function 
toggle(id) {
  $(
"#"+id).toggle();
}
</
script>
{/
literal
EDIT: now tested and adjusted
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote

The following user thanks cherie for this useful post:
Petepots (02-24-2014)
  #3  
Old 02-20-2014, 07:09 AM
  Petepots's Avatar 
Petepots Petepots is offline
 

eXpert
  
Join Date: Aug 2007
Location: Surrey, UK
Posts: 275
 

Default Re: Can anyone help in simple Javascript

Thank you so much Cherie, but my heads spining becuase I have never done Java. Let me show you whats happing

http://kingquick.co.uk/peters_files/forum/java_problem/main_prod_desc.jpg

As you will see I have sort of got there, but honestly no idea what I am doing

I put the code here
http://kingquick.co.uk/peters_files/forum/java_problem/product_details.jpg

The result I got
http://kingquick.co.uk/peters_files/forum/java_problem/full_product.jpg

I am not sure about the "#" sign going in the scrip because I can see the java scrips adds the "#" to the ID

Hope you can see better whats happing

Very kind regards and thank you

Peter
__________________
Version 4.7.2
Reply With Quote
  #4  
Old 02-20-2014, 08:54 AM
  cherie's Avatar 
cherie cherie is online now
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Can anyone help in simple Javascript

The # in the address at the bottom is normal in this case.

It looks like you are putting the Smarty code directly in the product description and I don't think that's going to work. I recommend leaving descriptions as just descriptions and put the code in the template where you want it to appear.

Your onclick link does not look correct. It needs to call the toggle() function with the id it should reveal, such as "moreDescr".
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #5  
Old 02-21-2014, 06:55 AM
  Petepots's Avatar 
Petepots Petepots is offline
 

eXpert
  
Join Date: Aug 2007
Location: Surrey, UK
Posts: 275
 

Default Re: Can anyone help in simple Javascript

Cherie

Still cant get this to work, let me explain

I have a varable called {$lng.txt_simpletext} and in there is says:
This is a simple extra
test

and the
$product.descr says:
This is the full description held in prod file



So I have to printout the description and as you can see it alows HTML code in it

<td class="descr">{eval var=$product.fulldescr|default:$product.descr}


Now this is where I cannot get it to work, I changed the "#" to javascript, still no luck. It look as if I am nearly there (see pic)

<a href="javascript:" onclick="toggle({$lng.txt_simpletext})">see more</a> <div id={$lng.txt_simpletext}> </div>

<script type="text/javascript">
function toggle(id) {
$("#"+id).toggle();
return false;
}
</script>

As you can see the {$lng.txt_simpletext} is coming out before I click the "see more"



http://kingquick.co.uk/peters_files/forum/java_problem/full_product2.jpg

Hope you can help, if you could cut and paste the javascript and fill it in where the varables should go, it would be a great help. I am very greatful for your help.

Kind regards

Peter
__________________
Version 4.7.2
Reply With Quote
  #6  
Old 02-21-2014, 09:29 AM
  cherie's Avatar 
cherie cherie is online now
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Can anyone help in simple Javascript

There's no need to change "#". I tested the code in my first post above and made some slight adjustments.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #7  
Old 02-24-2014, 07:03 AM
  Petepots's Avatar 
Petepots Petepots is offline
 

eXpert
  
Join Date: Aug 2007
Location: Surrey, UK
Posts: 275
 

Default Re: Can anyone help in simple Javascript

http://kingquick.co.uk/peters_files/forum/java_problem/finished.jpg


Look Cherie, looking just as I want it, also I have been able to put the coding in the product description BRILLIANT

Thank you so much for your time in helping me, most greatful

Kind regards

Peter
__________________
Version 4.7.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



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 01:10 PM.

   

 
X-Cart forums © 2001-2020