Author Topic: [SOLVED] Preview Button  (Read 1637 times)

0 Members and 1 Guest are viewing this topic.

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #15 on: September 02, 2007, 10:55:53 PM »
Code: [Select]
<html>
<head>
<script type="text/javascript">
function alertValue()
  {
  alert(document.getElementById('txt1').value);
  }
</script>
</head>
<body>

<textarea id="txt1">

</textarea>
<br />
<input type="button" onclick="alertValue()"
value="Alert value" />

</body>
</html>


that works with alert it will work in ajax for sure, i dont want to code that whole thing but with this you can have a great start ;D ;D 

Offline Timma

  • Enthusiast
  • Posts: 80
    • View Profile
Re: Preview Button
« Reply #16 on: September 02, 2007, 11:00:01 PM »
That still does not resolve his main problem, getting the information that a user typed into that box.

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #17 on: September 02, 2007, 11:05:51 PM »
That still does not resolve his main problem, getting the information that a user typed into that box.

i dont know how and why GG want this but its doesnt look good to refresh the page to see the preview on the other window LOL

for sure that dont solved the prob but if GG know AJAX then prob is solve

Offline GuiltyGearTopic starter

  • Addict
  • Posts: 1,692
  • Gender: Male
    • View Profile
    • Laboratori.al - Creative Web Geeks
Re: Preview Button
« Reply #18 on: September 03, 2007, 10:12:36 AM »
As it is a cms, i want the client to preview the content of the article before submiting. Actually it isnt very important, but just a feature i wanted to add and a "challenge" for myself. But i thought it a lot more easy in the beginning. Im no ajax expert but i doubt it would resolve my problem  :(

Offline GuiltyGearTopic starter

  • Addict
  • Posts: 1,692
  • Gender: Male
    • View Profile
    • Laboratori.al - Creative Web Geeks
Re: Preview Button
« Reply #19 on: September 03, 2007, 06:22:06 PM »
Bump.

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #20 on: September 03, 2007, 06:28:04 PM »
If you test my sample it shows an alert box displaying what yuo have type in your text area dude it no diff opening a new window to preview this may take a bit of work. see this sample sorry if i cant code this one for you but start here
http://www.w3schools.com/php/php_ajax_database.asp
 I hope you know how to open a new window using JS so iguess you can do this one

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #21 on: September 03, 2007, 06:32:47 PM »
or you can try just what this forum does to preview your post.

Offline GuiltyGearTopic starter

  • Addict
  • Posts: 1,692
  • Gender: Male
    • View Profile
    • Laboratori.al - Creative Web Geeks
Re: Preview Button
« Reply #22 on: September 03, 2007, 06:45:15 PM »
I test the javascript thing to get the textarea value, but as i previously said it shows the original value, not the modified one. For opening a new window with JS i can use window.open() but thats not my problem. What would i need ajax? What i want is get the value of the textarea and open a new window.

In this forum, the preview area is on top of the editor. I can easily do that, but i want to open a new window as i cant preview a real site template inside a small area.

Anyway thanks for helping.

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #23 on: September 03, 2007, 07:18:30 PM »
Code: [Select]

<html>
<head>
<script type="text/javascript">
function alertValue()
  {
  //alert(document.getElementById('txt1').value);
 


myWindow=window.open('','','width=200,height=100')
myWindow.document.write(document.getElementById('txt1').value)
myWindow.focus()

 
  }
</script>
</head>
<body>

<textarea id="txt1">
Hello world....This is a text area
</textarea>
<br />
<input type="button" onClick="alertValue()"
value="Alert value" />

</body>
</html>


OOOOOOKKKKKK  hope this one help try

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #24 on: September 03, 2007, 07:19:52 PM »
oooppp this is no php !!!

Offline GuiltyGearTopic starter

  • Addict
  • Posts: 1,692
  • Gender: Male
    • View Profile
    • Laboratori.al - Creative Web Geeks
Re: Preview Button
« Reply #25 on: September 03, 2007, 07:27:48 PM »
Pretty good example, but still the problem with "document.getElementById('txt1').value" as it will return the original value of the textarea  :(

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #26 on: September 03, 2007, 07:36:35 PM »
but you can remove those can you tell me what exactly you want?

Offline GuiltyGearTopic starter

  • Addict
  • Posts: 1,692
  • Gender: Male
    • View Profile
    • Laboratori.al - Creative Web Geeks
Re: Preview Button
« Reply #27 on: September 03, 2007, 07:46:58 PM »
I explained it several times but guess its a bit complicated :S. Think of the preview button here in phpfreaks, but it doesnt preview the text in the same page, but in a new window. The text to be previewed is in a textarea converted to a tinymce editor. The text value is filled with some data from the database (which actually are texts and formatting stuff for articles) and the user can make further editing to it. I want him to preview how the edited article will look on the site before actually submiting the changes. Does it make sense now?

Offline teng84

  • Fanatic
  • Posts: 3,546
  • Gender: Male
    • View Profile
Re: Preview Button
« Reply #28 on: September 03, 2007, 07:57:02 PM »
Look I  cant give you the exact output you want but it acts just what you need whats the problem with that you just need to modify and add some stuff there to fit your needs.

you said you want a code that opens a new window for preview will it does?
if you think this sample cant help you as well as ajax then theres no other way, leave this task and sleep LOL ;D ;D ;D
for sure you dont want the page to refresh just to have this new window!!!

SORRY thats all I can offer GUD LUCK ;)

Offline GuiltyGearTopic starter

  • Addict
  • Posts: 1,692
  • Gender: Male
    • View Profile
    • Laboratori.al - Creative Web Geeks
Re: Preview Button
« Reply #29 on: September 03, 2007, 08:00:55 PM »
Yeah lol, probably im going for an impossible approach. Right now i made it that when preview is pressed the form posts and shows a message "the preview page is generated. click this link to view it" and opens up the window. Its the best thing i can have for now.

Thanx for the help anyone. Im marking this as solved, as im aware its something pretty difficult.