Sie sind nicht angemeldet.

1

Montag, 4. Oktober 2010, 08:17

Random Text - Is it possible?

Hello guys,



is it possible to have a text field or showtext with random text?

Ex: each time user enter a page it shows a different text OR, each time the user clicks on a plugin it shows a different text.

Can be each line, or each paragraph being randomized.. don't know how, neither if it's possible.

Thanks!

Daniel

2

Dienstag, 5. Oktober 2010, 03:39

I'm not sure you can currently do it with krpano only, but it should be easy if you use a flash plugin, javascript or server-side scripting.

3

Dienstag, 5. Oktober 2010, 04:03

Thanks "Protected"!!

Unfortunately I know nothing about programming (flash, etc... )!!


The only thing i'm starting to get used to is krpano.

Does anyone know if it's possible?

Thanks again!
Daniel

4

Dienstag, 5. Oktober 2010, 04:13

I don't know much about javascript, but looking at the documentation you should be able to do something like this:

In your HTML file:

Quellcode

1
2
3
4
5
<script type="text/javascript">
  function getrandomnumber() {
	document.getElementById("krpanoSWFObject").set("rnumber", Math.random());
  }
</script>


In your XML in an event somewhere:

Quellcode

1
js(getrandomnumber());


would place a random number in the variable rnumber (as in get(rnumber);).

You could then use the same method to obtain a random word. Do you want words from a prewritten text or gibberish?


EDIT: There seems to be a variable called "random" in the xml root, though I don't know what it does. Maybe it returns a different result every time it's read?