No, it's not possible using only browser-based code. The code in the browser runs on the client machine . It has no way to save a file on the server by itself.
You will have to use some code on the server to achieve such thing.
Up vote -1 down vote favorite share g+ share fb share tw.
I have a webpage that asks which input fields user wants, based on the selection it should create a new HTML page. I.e. If I select 3 textboxes and 1 button then it should create new HTML page with 3 textboxes and 1 button.
How to do the same thing using PHP? Edit: my objective is newly created page should also be saved on the server at the time of creation php javascript html link|improve this question edited Mar 7 at 13:41Shadow Wizard22.3k31536 asked Mar 7 at 12:40Parth patel73.
Of course. You can create a complete DOM tree with Javascript. Start reading here.
But I guess your question is if there's a library to make this easy and maintainable? – Mr Lister Mar 7 at 12:42 Yes it is possible to add new elements to page using javascript. – arunes Mar 7 at 12:42 my objective is newly created page should also be saved on the server at the time of creation – Parth patel Mar 7 at 12:51 @Parthpatel: If you're going to completely change the question (which your comment above does), best to use the "edit" link and do it properly.
I've done it for you on this occasion. – T.J. Crowder Mar 7 at 13:08.
No, it's not possible using only browser-based code. The code in the browser runs on the client machine. It has no way to save a file on the server by itself.
You will have to use some code on the server to achieve such thing. You have two options: Create new window with the new content - once closed it will be gone as you can't save it to the server but for all other matters it will act as real HTML page. Using simple server side logic you can use AJAX to interact with it and create the pages.
3 You underestimate Javascript. And the OP isn't asking how to create a new HTML file on the server. – Mr Lister Mar 7 at 12:44 create new HTML page - sorry, to me it sounds like he is asking to create new HTML file on the server.
– Shadow Wizard Mar 7 at 12:47 1 What the OP wants (having dynamically created controls that the user can post) doesn't require creating a file on the server. As long as you have something on the server that you can post to! – Mr Lister Mar 7 at 12:51 Edit: of course, now the OP posts a new comment... – Mr Lister Mar 7 at 12:52 1 "JavaScript is client side language" No, no, a thousand times no.
JavaScript is just a language. It is no more tied to the client-side browser than Java is tied to thick applications written with Spring. NodeJS and Rhino are just two examples of JavaScript on the server.
Heck, even classic ASP a'la 1996 supported server-side JavaScript, as did Netscape server even earlier. I wrote whole apps back in the date using JavaScript and ASP. I still use JavaScript server-side (and in console scripts) nearly every day.
– T.J. Crowder Mar 7 at 13:04.
Update: You've added a comment to your question: my objective is newly created page should also be saved on the server at the time of creation That completely changes your question. To create a file on the server, you'll have to involve a server-side language (which could be JavaScript, via NodeJS or Rhino or several other projects) as well as JavaScript on the client. You'll need to post the user's choice to the server and generate the file there.
Original answer: (Prior to the comment above) Yes, you can do that. You can either show them a page where they make these choices and then replace that page's content with what they asked for, or you can open a new window and show their selection there. In either case, you'd probably use the DOM: DOM2 Core spec DOM2 HTML spec DOM3 Core spec HTML5 Web Application APIs ...and/or a good JavaScript library like jQuery, Prototype, YUI, Closure, or any of several others to help smooth over browser differences and provide significant utility functionality.
Here's a really minimalist example using only DOM and JavaScript (no libraries, but I do strongly recommend using one, the code would be leaner and more robust): Live copy | Live source HTML: How many text boxes would you like? One Two Three JavaScript: (function() { document. GetElementById("btnGo").
Onclick = genPage; function genPage() { var sel = document. GetElementById("numboxes"), num = parseInt(sel.optionssel.selectedIndex. Value, 10), counter, box; document.
GetElementById("btnGo"). Onclick = ""; document.body. RemoveChild(document.
GetElementById("question")); for (counter = 0; counter AppendChild(box); } } })().
There are several ways to achieve this. One way is simply creating the page dynamically from your server using whichever templating or page creation mechanisms you have in place. You could use e.g. Jquery or zeptojs for an ajax request and then reload the current page with the new elements returned from the server.
Another way would be to create a js (jquery and similar libraries are good for this stuff) function which changes the html elements after the submit button has been clicked. Check out jquery.
Below are some crude step by you can achieve this (only if your's is plain . Html page) Add a blank div to your html page e.g. (all the controls will be added in this container). Capture the user entered control info into some variables.
Run a for loop over (count can be calculated based on number of controls user wants) $('#page'). Html(\\plain html code to add controls).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.