Solved

script

Posted on 2004-04-17
6
160 Views
Last Modified: 2010-04-09
I need a script which allows a visitor of my page to enter his name => the name is added to a list of other visitors which is shown in (the same) HTML document
is this possible? (I can't use PHP on my page)
thanks
0
Comment
Question by:ViP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 10850212
<html><head>
</head>
<body>
<p id="Vlist">
visitor one<br />
visitor two<br />
visitor three<br />
visitor four<br />
visitor five<br />
visitor six<br />
</p>
<form>
enter your name:
<input type="text" name="newV">
<input type="button" value="Add to list"
onClick="document.getElementById('Vlist').innerHTML+=this.form.newV.value+'<br />'">
</form>
</body>
</html>


That will display it on teh screen, but it will not save it permanently unless you send ot the server and save the information with scripting.

Cd&
0
 

Author Comment

by:ViP
ID: 10850255
and how do you send it on the server?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 25 total points
ID: 10850375
do th eform part this way:

<form action="yourscript.cgi">
enter your name:
<input type="text" name="newV">
<input type="button" value="Add to list"
onClick="document.getElementById('Vlist').innerHTML+=this.form.newV.value+'<br />'">
<input type="submit" value="Save list">
</form>

But will still not save it you have to have a server side script to add the new name.

Cd&
0
 
LVL 1

Assisted Solution

by:pcazella
pcazella earned 25 total points
ID: 10851445
First, is sounds like you need a small database of vistior names.  Access, MySQL, DB2, SQL....whatever you've got.  Or you could use the file scripting and work with Text files...but I like DB's

Here is a quick ASP / Access version.

---------------
<% Language"VBscript" %>
<% strConn= "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=MyDB.mdb"
<%
If Request("Submit') <> ""  then
set Command1 = Server.CreateObject("ADODB.Command")
Command1.ActiveConnection = strConn
Command1.CommandText = "INSERT INTO  Names  VALUES " & Request("NewName")
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()

End if
%>

<%
Dim GetNames
Dim GetNames_numRows

Set GetNames = Server.CreateObject("ADODB.Recordset")
GetNames.ActiveConnection = strConn
GetNames.Source = "Select Names from tblNames ORDER BY Names"
GetNames.CursorType = 0
GetNames.CursorLocation = 2
GetNames.LockType = 1
GetNames.Open()

GetNames_numRows = 0
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>My Visitors</title>
</head>

<body>
<table width="100" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <%
While ((Repeat1__numRows <> 0) AND (NOT GetNames.EOF))
%>
  <tr>
    <td><%=(GetNames.Fields.Item("Name").Value)%></td>
  </tr>
  <%
  Repeat1__index=Repeat1__index+1
  Repeat1__numRows=Repeat1__numRows-1
  GetNames.MoveNext()
Wend
%>

</table>
<form name="form1" method="post" action="">
  <table width="100" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td>Add Your Name </td>
    </tr>
    <tr>
      <td><input name="NewName" type="text" id="NewName">
      <input type="submit" name="Submit" value="Submit"></td>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
</body>
</html>
<%
GetNames.Close()
Set GetNames = Nothing
%>


you can tear it apart but bacially here is the outline:

Declare your DB location
If sumbitted insert a new record
Get all records
Display all records
Create a form
Input fields and submit button
Close the recordset

0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Find out what you should include to make the best professional email signature for your organization.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question