Autor Beitrag
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Do 17.05.07 18:08 
Hallo und Prost :beer: heut zum Männertag. :D
ich habe ein Problem bei meiner Webseite(einfach unten auf Webseite klicken). Ich habe links ein Menü und dort soll über das Miniwetter noch eine Spruchbox hin (keine SB). Dort möchte ich einige Zitate von mehr oder weniger berühmten Personen anzeigen lassen. Ich wollte auch, dass es einen Befehl gibt, um den nächsten Spruch auszuwählen. Dazu habe ich mir ein php-Script geschrieben, was aus meiner MySQL-Datenbank einen Spruch zufällig auswählt. Nun wollte ich, dass es den Spruch anzeigt. Leider klappt das ganze nicht. Wie muss ich das Java-Script schreiben, dass es den Spruch zwischen die div-tags schreibt?

MfG
Regan
chaoskeeper
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Do 17.05.07 18:36 
hallo,

Ich weiss nicht ob es möglich ist direkt Text in einem Div zu ändern, aber es gibt einen Umweg (falls es wirklich nicht möglich ist)
Also ich würde eine Textarea in die div machen, und dann einfach deren "value" ändern.

Per CSS kanns du die Textarea dann ohne Rand,scrollbar und hintergrundfarbe definieren, dann ist sie auch visuell nicht zu sehen.

happy hunting
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 17.05.07 18:39 
ausblenden Quelltext
1:
getElementById('myDIV').innerHTML = 'Neuer Text';					

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
chaoskeeper
Hält's aus hier
Beiträge: 9



BeitragVerfasst: Do 17.05.07 18:45 
user profile iconGTA-Place hat folgendes geschrieben:
ausblenden Quelltext
1:
getElementById('myDIV').innerHTML = 'Neuer Text';					


das klingt gut, nur ne Frage, fehlt da nicht "document."?

also document.getElementById('myDIV').innerHTML = 'Neuer Text';

Moderiert von user profile iconChristian S.: Code-Tags hinzugefügt
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 17.05.07 18:51 
Jop, aber da wäre er sicher selbst draufgekommen. Ich will ihm ja nicht die ganze Lösung präsentieren.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Do 17.05.07 21:43 
user profile iconGTA-Place hat folgendes geschrieben:
ausblenden Quelltext
1:
getElementById('myDIV').innerHTML = 'Neuer Text';					

OK. Hab ich mal so hingeschrieben. Aber wie binde ich nun den Text der PHP-Datei ein?
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 17.05.07 21:59 
Indem du die Funktion mit <?php echo('<script type="txt/javascript">myFunction("'. $meintext .'");</script>'); aufrufst.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mi 30.05.07 10:47 
Wofür brauchst du da denn javaScript und ein iFrame?

Du kannst das ganz simpel mit einem echo am gewünschten Platz lösen.

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Mi 30.05.07 16:21 
weil ich das ganze dynamisch lösen will. Man soll auc einen Button im I-Frame klicken und dann soll sich der inhalt des frames ändern (ähnlich der SB hier im DF). Ich denke auch dass ich es so ähnlich lösen werde.
allerdings hab ich die sache grad nicht in der mangel, weil wir in bald arbeiten schreiben.
Pepe
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 107

Win 98, Win 2000 Prof., Win XP Prof.
Delphi 2005 Prof.
BeitragVerfasst: Mi 30.05.07 17:53 
das ist genau das, was christian meint, bei einem ifframe brauchst du kein javascript...

da setzt du einfachen nen link auf das script (was dir nen comment per zufall auswirft) und gut ist...
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Mi 30.05.07 18:03 
Genau, das JavaScript wird hier nur verwendet, um da Iframe separat zu aktualisieren, nicht aber um die Shoutbox zu generieren.

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Do 31.05.07 14:35 
user profile iconPepe hat folgendes geschrieben:
das ist genau das, was christian meint, bei einem ifframe brauchst du kein javascript...

da setzt du einfachen nen link auf das script (was dir nen comment per zufall auswirft) und gut ist...

Und wie mach ich das da?
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Do 31.05.07 14:45 
ausblenden Quelltext
1:
<iframe ... src="Zitate.php" ...>					

ausblenden Zitate.php
1:
2:
3:
<?php
  echo('Es war einmal...');
?>

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Do 31.05.07 20:51 
jo. das hab ich ja. bei mir werden die sprüche aus einer mysql-datenbank geladen (mit autor und text). dabei wird eine zufallszahl gebildet (nach der anzahl der einträge).
aber wie mach ich jetzt, dass ich da nen neuen spruch her kriege, ohne die seite neu zu laden? Das muss ich doch mit Javascript machen oder?
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Sa 02.06.07 13:12 
Ich denke da kommst du wohl um ein iFrame nich herum so wie hier im DF.

Script:
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
<script type="text/javascript" language="javascript1.2">
function AktualisiereShoutBox()
{
namedershoutbox.location.href = 'adresse_vom_php_srcipt';
}
</script>


Iframe:

ausblenden C#-Quelltext
1:
<iframe src="adresse_vom_php_script" name="namedershoutbox" />					


Der Button zum aktualisieren:
ausblenden C#-Quelltext
1:
<input type="button" OnClick="AktualisiereShoutBox()">					

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
Regan Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Sa 02.06.07 13:56 
Danke. Genau so wollte ich das haben. :D
Ich habe aber noch frameborder=0 gestellt. Dann sieht es so aus, als würde der Text ganz normal dort stehen. :wink: