Solved

script

Posted on 2004-04-17
6
159 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

730 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