Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

script

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

610 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