Jump to content

Store a variable at form submit


Recommended Posts

Hi folks, I'm facing a bit of a snag here.I'm making a CMS manpage to alter the content for my website. I divided the workload into chunks to keep it all manageable, so far I have template related database info, a news manpage, and a management page to add and alter 'html' pages.Each manpage is a form or a set of forms, which gets loaded into a DIV using the XmlHttpRequest (think 'AJAX'). So I have one index.html, and a menu decides which variable is used to load the related PHP script.I have the function that loads stuff check if a variable already exists, and if not it uses a default value.

	if (!serverPage) {		var serverPage = 'tempmanpage.php';	}

I tested this CMS manpage succesfully for the first script, tempmanpage.php (which manages information loaded for the template).When I use AJAX to load the script called defmanpage.php, the page to manage default HTML pages stored into the database, it shows as expected. I embedded a form with a dropdown menu to decide whether I want to create a new page or alter an existing one. A textarea is opened containing the HTML code for the page I want to alter or containing nothing at all if I want to create a new page. The action for this form is obviously index.html, because I want to reload my PHP script to create the textbox and fill it with the desired info. The problem is my javascript uses the default value (tempmanpage.php) and not the value for the last visited page (defmanpage.php).So the question is quite simple: I want my index.html to load a specific page when I click Submit. Is there any way to do so? Do I have to migrate my form from PHP to Javascript, and if so, what would be the best approach? I'm far more familiar with PHP than with Javascript.

Link to post
Share on other sites
[...]The action for this form is obviously index.html, because I want to reload my PHP script to create the textbox and fill it with the desired info. The problem is my javascript uses the default value (tempmanpage.php) and not the value for the last visited page (defmanpage.php) [...]
I haven't used PHP but from other server-side scripting I would say your index.html could become a server-side scripted (php?) page, so that within it, you could generate that javascript function with the appropriate default value of that variable:
if (!serverPage) {	var serverPage =  (php to write name of correct page, based on what was submitted)}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...