-
Musical chair
PHP (+javascript?) button to change text w/o reloading page
Hello all
So, right now I'm designing a site with php, and I wanted to add a textbox with arrows on either side which, when clicked, will change the text in the textbox without having to reload the page.
The textbox's text is also going to be loaded from an external *.txt document. I was thinking of having different messages separated by 'at signs' which would be extracted, then explode the 'at signs' to put the data in an array, which could then be scrolled through, via the arrow buttons said above. (If there's a more efficient way, let me know.) The array would have a changing length.
I would try to figure it out with Google, but I don't know what to search...I remember learning this years and years ago, but I don't have a clue anymore.
Thanks!
-
These doesn't necessarily have anything to do with PHP. Unless you happen to be using AMFPHP or some kind of PHP-Actionscript serializer class in your flash movie, then Flash is going to receive the data from a text file or PHP as one string of characters. If you devide your content using & instead of @ then Flash can automatically split it for you but you'd need to assign name-value paris like this.
Code:
var1=value1&var2=value2&var3=value3
Perhaps you could give a little more info about what you are trying to do and why you think you need php?
-
Hi,
here is a simplistic javascript example to populate a textbox from vars in the script.
I am not sure whether this is what you wanted...
Code:
<script>
var texts = Array('this is first text<br>multiline', 'another text');
function showtext(n)
{ document.forms.form1.ta.innerHTML = texts[n];
}
</script>
<form name=form1>
<textarea name=ta rows=5 cols=50></textarea><br>
<input type=button value=text1 onclick='showtext(0)'>
<input type=button value=text2 onclick='showtext(1)'>
</form>
Musicman
-
Musical chair
@ Sneakyimp
I'm only really using php for the loading of the variables to be put into the textbox; I know the actual replacement of the text requires no php; I'm just saying that's the page type.
@ Musicman
Thanks! That was really close to what I had in mind; I'm glad you could understand..
Is there any way for the user to be unable to type/enter/delete information from the textbox? aka not really a textbox, but just text in an html table.
Thanks again, guys
-
Hi,
a textarea does not seem to have a readonly property. You can use the innerHTML with a simple <div> instead of a textarea, so if you can use css style properties to make the div look like a textarea, you are fine
Musicman
-
Musical chair
Thanks! The InnerHTML was exactly what I needed
-
Musical chair
Sorry, one more thing...
Say I have an array of 5 objects in javascript. I have a button that says "prev" and another, saying "next." how can i make it so that "prev" makes InnerHTML show the previous item in the array, while "next" uses InnerHTML to show the next in the array, while stopping at the last item and going no further?
Thanks again
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|