Jump to content

transfer content to other page


T-Bone

Recommended Posts

Hi,I have a html page with i want to update weekly with new content that override the old content.To be able to do that without having to go through the html-codes, i want to use something like a form that i fill in and the content/data from that form will be transferred to the other page and overrides the old content.I guess it would need a html from page and on the real content page the data is enter via javascript or is there another way.And if this is the way how should i set it up.Cheers,T-Bone

Link to comment
Share on other sites

Since your page lives on your server, all changes must also take place on your server. You probably have access to a serverside environment like PHP of ASP.NET. To do what you are doing will require a way to send data to your server, a way for your server to make changes to the page data, and a way for the server to save the updated document.You could of course move to a complete content management system (CMS) but that might be a lot of effort if you see yourself doing this for only a few pages.

Link to comment
Share on other sites

Yes the both pages will be on the same server. The main page will be visible and the other will be secured i think.The idea is now i am writing stuff without any layout to the page. i want to have a web based layout now everything i redo the report. Which is every week.i will not be the only one doing this so to be able to have members add the report they shouldn't have to know anything about html or anything just fill in the form and submit and the front end page will show the content.

Link to comment
Share on other sites

i will not be the only one doing this so to be able to have members add the report they shouldn't have to know anything about html or anything just fill in the form and submit and the front end page will show the content.
"they shouldn't have to know anything about html" Does this include formatting?, <h1> to <h6>, <p>, <b>, <strong>, <i>, <em>, and even images? if just plain text, you could enter text into form textarea (area to represent page width), store in database table text field on submit, and then insert content within <pre> ...</pre> tags within the actual page, a double return, could give the effect of a new paragraph.with some cms systems they use an html editor which allows you to paste from word document, with the most common formatting features included.
Link to comment
Share on other sites

Without knowing how advanced your server-side skills are, it is hard to offer more detailed advice.
What can i tell you more, there is no need for a layout or anything just plain text.There is now CMS i am using, but i know asp is running on the server.Do you have an example of lets say a textbox and a code to show anything you enter in the textbox and submit on that page.I just want it as easy as it can get.I don't know if i am an average skilled in html, css, xml. i can read them and understand and create mine own if i know the way to do it.If i can get an simple example i could build it further myself.
Link to comment
Share on other sites

This is not possible with simple a markup language and CSS - you'll need to use server-side scripting. If you read the tutorials (such as the ASP one), you will get a better idea of the effort you will need to put in.

Link to comment
Share on other sites

This is not possible with simple a markup language and CSS - you'll need to use server-side scripting. If you read the tutorials (such as the ASP one), you will get a better idea of the effort you will need to put in.
Ahh ok, the server is running ASP. So i should be able to use that.I guess i can use the action= to send the data to an ASP-file. and then i need a script to load it in that file to show it on the page using ASP.What code should i use to load it in the ASP-file?It the effort what makes building site so fun.
Link to comment
Share on other sites

You going to have to store the text in any case, whether by using access database, mssql or maybe a simple xml file which might be the best option to go with.here is a simple textearea form to accept text and store in xml file, it only works in IE browser, but this maybe because i have php/mysql server installed, and when i run the iis server for asp, FF treats it as another domain, and because of security it throws an access denied error.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Untitled Document</title></head><body><!-- To write contents of form to test.xml file --><%header_text = Request.Form("header")body_text = Request.Form("pagetext")If (body_text <> "" and header_text <> "" and header_text <> "enter heading here") Thentext="<page>"text=text & "<header>" & header_text  & "</header>"text=text & "<body_text>" & body_text  & "</body_text>"text=text & "</page>"set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")xmlDoc.async="false"xmlDoc.loadXML(text)xmlDoc.Save("test.xml")End If%><!-- form for inputting content --><form action="pagetext.asp" method="post"><input type="text" value="enter heading here" name="header" /><div><textarea name="pagetext" cols="" rows="" style="width:800px; min-height:400px;"></textarea></div><input type="submit" value="Submit Text" /></form><h1 id="header">Header Blah Blah Blah</h1><div  id="body_text" style="width:800px; background-color:#F4F4F4; white-space:normal;">Content blah. blah blah</div><!-- To read contents of test.xml file into html page --><script type="text/javascript">/*<![CDATA[*//*---->*/if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.open("GET","test.xml",false);xmlhttp.send(null); //add null for FF fixxmlDoc=xmlhttp.responseXML;ss = xmlDoc.getElementsByTagName("body_text")[0].childNodes[0].nodeValue;ss = ss.replace(/(\r\n)|(\n)/g,"<br />");document.getElementById("header").innerHTML = xmlDoc.getElementsByTagName("header")[0].childNodes[0].nodeValue;document.getElementById("body_text").innerHTML = ss;/*--*//*]]>*/</script></body></html>

EDIT: adding null to send() as in send(null) seems to fix ff problem.

Link to comment
Share on other sites

Cheers Mate,I will be testing this, just to get the whole picture.I create the file pagetext.asp with all the codes in it.This will then create the test.xml file which can then be checked for the content by an html page.the html page will then display the content i typed in the form of the pagetext.asp file. if i use the last part CDATA in that html page.

Link to comment
Share on other sites

yes, all you do is add header title, and then content, hitting the return key twice within the textarea will produce an paragraph effect.when you submit, it posts the data to itself 'pagetext.asp'

<!-- To write contents of form to test.xml file --><%header_text = Request.Form("header")body_text = Request.Form("pagetext")If (body_text <> "" and header_text <> "" and header_text <> "enter heading here") Thentext="<page>"text=text & "<header>" & header_text  & "</header>"text=text & "<body_text>" & body_text  & "</body_text>"text=text & "</page>"set xmlDoc=Server.CreateObject("Microsoft.XMLDOM")xmlDoc.async="false"xmlDoc.loadXML(text)xmlDoc.Save("test.xml")End If%>

if the posted data is not equal to "" (emptystring) or default value of heading input "enter heading here", it will be saved in a xml file called test.xml.small point in my script i had to use absolute path "E:\Inetpub\wwwroot\test\test.xml" for it to work, but as i said my server is for php, and i did temporary asp server setup to get it to work, so if you have problems writing using just 'test.xml' try using absolute path instead.the code to read the xml file is

<h1 id="header">Header Blah Blah Blah</h1><div  id="body_text" style="width:800px; background-color:#F4F4F4; white-space:normal;">Content blah. blah blah</div><!-- To read contents of test.xml file into html page --><script type="text/javascript">/*<![CDATA[*//*---->*/if (window.XMLHttpRequest)  {// code for IE7+, Firefox, Chrome, Opera, Safari  xmlhttp=new XMLHttpRequest();  }else  {// code for IE6, IE5  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");  }xmlhttp.open("GET","test.xml",false);xmlhttp.send(null); //add null for FF fixxmlDoc=xmlhttp.responseXML;ss = xmlDoc.getElementsByTagName("body_text")[0].childNodes[0].nodeValue;ss = ss.replace(/(\r\n)|(\n)/g,"<br />");document.getElementById("header").innerHTML = xmlDoc.getElementsByTagName("header")[0].childNodes[0].nodeValue;document.getElementById("body_text").innerHTML = ss;/*--*//*]]>*/</script>

the content in<h1 id="header">Header Blah Blah Blah</h1><div id="body_text" style="width:800px; background-color:#F4F4F4; white-space:normal;">Content blah. blah blah</div>will be replaced with the text from test.xmlthe ss = xmlDoc.getElementsByTagName("body_text")[0].childNodes[0].nodeValue;ss = ss.replace(/(\r\n)|(\n)/g,"<br />");replaces \n (newline) or \r (returns) with <br />, without this you would end up with an big block of text, with no paragraph effect (really two '<br />')This will overwrite any text within the test.xml file, but you could use timestamp within the filename test-20110114-19-24.xml then look for latest timestamp value within those filenames, so you will have backup of each story submitted, and something to fallback on. Just something to consider.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...