Solved

script

Posted on 2004-04-17
6
155 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
  • 2
6 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
<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
Comment Utility
and how do you send it on the server?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 25 total points
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now