Welcome to TalkGraphics.com
Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1
    Join Date
    Oct 2016
    Location
    Rochford
    Posts
    124

    Default Different text every time website loads

    I would like to put a customer review on my home page with a link to a another page with more reviews on it. I want the review text to be in a speech bubble, all of this is simple but.....
    does anyone know if I can get the review to change to a different one every time the website loads and how to do this.

    Thanks.

  2. #2
    Join Date
    May 2015
    Posts
    290

    Default Re: Different text every time website loads

    Hi ianzzz5,

    Easiest way (IMO) is to have some JavaScript generate a random number(between 0 and 1) on page load. Have a JS array which has all your reviews, and multiple this random number by the number of entries in the Array. Then have a document.write(array(value of the random number * the number of array entries).

    I think I have an example somewhere, which I'll add when I find it.

    Thanks,
    Ben

  3. #3
    Join Date
    Oct 2016
    Location
    Rochford
    Posts
    124

    Default Re: Different text every time website loads

    Thank you, I would appreciate that as this looks a bit complicated for me.

  4. #4
    Join Date
    May 2015
    Posts
    290

    Default Re: Different text every time website loads

    Hi ianzzz5,

    Couldn't find the original but here is a (really) quick example, I haven't really tested it but it should work in all browsers and Devices, the placeholder just becomes a Div with text in it, so you can resize it, drag it around and design around it, if you have any questions let me know and ill add a FAQ to the file. Just double click the placeholder to see the code inside and insert your tips in.

    randomTipBox.xar

    Thanks,
    Ben

  5. #5
    Join Date
    Oct 2016
    Location
    Rochford
    Posts
    124

    Default Re: Different text every time website loads

    Hi Ben,

    Thank you very much, that's exactly what I'm looking for.
    Would you know how I can change the font and font colour please, and also add a couple more lines to each Tip.

    e.g.

    Mr & Mrs D

    A couple of lines of text
    A couple of lines of text

  6. #6
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,823

    Info Re: Different text every time website loads

    Quote Originally Posted by ianzzz5 View Post
    Hi Ben,

    Thank you very much, that's exactly what I'm looking for.
    Would you know how I can change the font and font colour please, and also add a couple more lines to each Tip.
    e.g.
    Mr & Mrs D
    A couple of lines of text
    A couple of lines of text
    ianzzz5, you need to follow this closely.

    Create a (Xara) text box (not a line) with some placeholder text to the font size and type you want. This includes left, right, centre and full alignment.
    This text will be replaced but the settings will remain.

    In this text box's Placeholder HTML code (body), add the following:
    Code:
    <div id="textBox">&nbsp;</div>
    
    <script>
      var tip=new Array()
      tip[0]="<span style='color:red;'>Tip 1: Mr & Mrs D</span>"
      tip[1]="This is Tip 2"
      tip[2]="This is Tip 3"
      tip[3]="This is Tip 4"
      tip[4]="This is Tip 5"
      tip[5]="This is Tip 6"
      tip[6]="<span>Tip 7: A couple of lines of text<br />A couple of line of text</span>"
      tip[7]="<span>Tip 8: Another line of text"
      
      var randomTip=Math.floor(Math.random()*tip.length)
      document.getElementById("textBox").innerHTML = tip[randomTip];
    
    </script>
    To change to a different colour you need to add HTML code as shown.
    Tip 6 technically does not need the span Tags but if you are wanting to tweak things you need them to hang the tweaks around in some in-line CSS.

    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  7. #7
    Join Date
    Oct 2016
    Location
    Rochford
    Posts
    124

    Default Re: Different text every time website loads

    Works really well.

    Thanks for all your help.

  8. #8
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,823

    Default Re: Different text every time website loads

    Glad we can help.

    To address your original query, the next step would be to include links in the Tips:
    tip[8]=<span>Tip 8: This text has a <a href='http://www.mysite.biz/' target='_blank'>link</a>%nbsp;that you should visit</span>
    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

  9. #9
    Join Date
    Oct 2016
    Location
    Rochford
    Posts
    124

    Default Re: Different text every time website loads

    Quote Originally Posted by Acorn View Post
    Glad we can help.

    To address your original query, the next step would be to include links in the Tips:


    Acorn
    Thanks but have decided to put a button to go to a 'review' page.

  10. #10
    Join Date
    Apr 2012
    Location
    SW England
    Posts
    17,823

    Default Re: Different text every time website loads

    Quote Originally Posted by ianzzz5 View Post
    Thanks but have decided to put a button to go to a 'review' page.
    No problem, others might have a need,
    Acorn
    Acorn - installed Xara software: Cloud+/Pro+ and most others back through time (to CC's Artworks). Contact for technical remediation/consultancy for your web designs.
    When we provide assistance, your responses are valuable as they benefit the community. TG Nuggets you might like. Report faults: Xara Cloud+/Pro+/Magix Legacy; Xara KB & Chat

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •