SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    UK
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    js preview function

    Ok at the moment im creating a generator and i would like to be able to have a new window open with the information fro the generator on it so basicly a preview button.

    i was wondering how to do this and also how to incorperate it into the current javascript i have written, the js for the generaotr is as follows.

    Code:
    <script>
    function generate(type){
     document.getElementById("script").value = document.getElementById("hidden").value;
     for(i=1;i<8;i++){
      document.getElementById("script").value = document.getElementById("script").value.replace('['+i+']',document.getElementById("i"+i).value);
     }
    }
    </script>

    i fount this script but i couldnt get it to work.
    Code:
    function displayHTML(form) {
    var inf = form.htmlArea.value;
    win = window.open(", ", 'popup', 'toolbar = no, status = no');
    win.document.write("" + inf + "");}
    this is the input button to make the preview work.

    Code:
    <input type="button" value=" view " onclick="displayHTML(this.form)">

    any hel pwould be great.

  2. #2
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    UK
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anybody?

  3. #3
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What's a generator?

  4. #4
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you manage to get it working, the ids you are using will come back to haunt you.
    Last edited by mrhoo; Oct 7, 2006 at 16:57. Reason: spell check

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I clicked on your link for generators, it's a web form that lets the user "generate" some kind of html fragment.

    Is this the sort of thing you are looking to do?
    Code:
    <html>
    <head>
    <script type="text/javascript">
    function makeBG(color) {
    	var theHTML = "<html><body style='background:" + color + ";'>testing</body></html>";
    	var w = window.open("");
    	w.document.write(theHTML);
    }
    </script>
    </head>
    <body>
    <form>
    	<select id="theselect">
    		<option value="black">black</option>
    		<option value="blue">blue</option>
    		<option value="red">red</option>
    	</select>
    	<button onclick="makeBG(document.getElementById('theselect').value);">Click to generate</button>
    </form>
    </body>
    </html>

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2004
    Location
    UK
    Posts
    86
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey guys, sorry for the wait.

    The generator im making is s oyou can make a webtemplate using html forms. your example is on the right track.

    what i want to do is make it so you fill all the input boxes out then click generate and then click preview and the html that is generatored will be opened into a new window displying the template.


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
  •