登录 | 注册 | FAQ
Anonymous

how to save user text to website?

+ 发表回复

2 篇帖子 分页: 1 / 1


how to save user text to website?

james173 » 周日 12月 12, 2010 4:30 pm

hi,
I need to make a button that when pressed will create a textbox next to it. Then once the user has written in the textbox and pressed another button; "save" the textbox will be saved so anyone else who goes on the site can see it.
Does anyone know how to;
1. make a button that can create a textbox?
2. Save edited text to the website?
Thanks
头像

james173

  • 帖子: 2
  • 注册: 周六 12月 11, 2010 4:20 pm

Re: how to save user text to website?

frank » 周日 12月 12, 2010 9:47 pm

james173 写道:hi,
I need to make a button that when pressed will create a textbox next to it. Then once the user has written in the textbox and pressed another button; "save" the textbox will be saved so anyone else who goes on the site can see it.
Does anyone know how to;
1. make a button that can create a textbox?
2. Save edited text to the website?
Thanks


You'll have to save the new fields in a table column. so you want to make a form and upon submission and validation on server side (use php or asp), you'll insert the outerHTML into the table column. next time you open the page, you query the column and show the field. here is a snippet of the js part.
代码: 全选
<html>
<head>
<script type="text/javascript">
function addElement()
{
 
  var newInput = document.createElement("input");
  newInput.id= "customInput";
  newInput.className = "custom-input";

  var saveBtn = document.getElementById('save');
  document.body.insertBefore(newInput, saveBtn);
}
function saveform()
{
  var userinput = document.getElementById('customInput');
  if(userinput) {
   alert(userinput.outerHTML)
  }
}
</script>
</head>

<body>


Let me know if you need addition help.

web hosting reviews
头像

frank

  • 帖子: 18
  • 注册: 周二 11月 30, 2010 7:37 pm


+ 发表回复

分页: 1 / 1