How do I change HTML content to be a JS variable?

Need a script to change a html/php page content?

  • I need a script to change a form's content from <input type="file" name="gaurav[]" /> to <input type="url" name="url" /> when user click a text- Upload from url. Thanks in advance!!

  • Answer:

    If your familiar with building links, you could send input data in a $_GET variable, paste your validation code then redirect to a dynamic link built with the same location as the 1st input. Set up statements to control what to display: <?php if(isset($_POST['gaurav'])){ //Code to validate POST data from input 1 header("location:index.php?postData = true") } if (isset($_GET["postData"])) { echo '<input type="url" name="url" />'; //Code to validate POST data from input 2 } //....and so on ?> That's just a crude example of using GET to dynamically display data through links, best used with urlencode() for security measures, POST already does this. You'll want to refresh the page for each click and use conditionals to decide what to display next. This is best done with an MVC framework like CodeIgniter.

Gamer at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

You do NOT want to do that. The moment you make a page writeable you have set up a big hole in the site security. Any hacker can post a script link in their typed url and that link can then make the page edit to include their own code. A common use for this is to make the site an open spam relay if it is hosted as usual on a server with access to email. another is to make your site re-direct as a bank account phishing site, or worse a child porn site. This is often then also used to gain access to other pages on the site. A very quick way to get your site blocked. If you want content on a page to change the correct way is to use a database and then use php to read in appropriate data as required, this allows totally dynamic page building according to user, and the type of content you want to show them. For the operation you show, the best option if to make the click swap out one type and name one as a property of the page and swap in the other type and name using Javascropt onclick. So the page never changes.

Colinc

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.