?
Solved

script

Posted on 2004-04-17
6
Medium Priority
?
161 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 100 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 100 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
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)
Suggested Courses

777 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