Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submitting a value to asp script from a form 2

Status
Not open for further replies.

werD420

Technical User
Sep 14, 2004
181
US
Thanks For any Help I can get Im stumped
Hey all Im having some trouble with this code it says i need to set a function for request.form I thought this was a standard
My form post to this script and then hits a database to match the id with the text box from that it gets the filename for a java applet to load here is the script

<%@Language = "VbScript"%>
<!--#include file="adovbs.inc"-->
<%
dim objConn,objRec
set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open "Data Source=" & Server.Mappath("../nes/GAMETABLE.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"
Set objRec = Server.CreateObject ("ADODB.Recordset")
objRec.Open "SELECT [ID], [Filename] FROM NESgames WHERE [ID]=Request.form",objConn,adOpenKeyset,adLockOptimistic, adCmdText
%>

<%

While NOT objRec.EOF

response.write "<applet code = NESCafeApplet archive =""NESCafe056.jar"" width =256 height =240> <param name=ROMFILE value=""games/"" &objRec(""filename"") ""> <param name=LIGHTGUN value=""false""> <param name=SOUND value=""true""> <param name=LOADSTATE value=""""> </applet>"

Wend

%>
 
Ok Ive gotten The applet to load but instead of writing the field "filename" it writes <param name=ROMFILE value="games/" &objRec("filename") ">

Any Thoughts thanks again
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<!--#include file="adovbs.inc"-->
<%
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Data Source=" & Server.Mappath("../nes/GAMETABLE.mdb") & ";Provider=Microsoft.Jet.OLEDB.4.0;"


game = Request.Form("game")

Set rs = Conn.Execute("SELECT [ID], [FileName] FROM NESgames WHERE [ID] = " & game)

If Not rs.eof Then
Response.Write("<applet code = NESCafeApplet archive =""NESCafe056.jar"" width =256 height =240> <param name=ROMFILE value=""games/"" &objRec(""filename"") ""> <param name=LIGHTGUN value=""false""> <param name=SOUND value=""true""> <param name=LOADSTATE value=""""> </applet>")
End If

Conn.Close
Set Conn = Nothing
%>
</body>
</html>
 
I'm lost in that code. Try formatting it first off. please for the chance someone may have to work on it later on.

Maybe a explanation of what;s going on up there along with a few tutorials in writing ASP's will help out.



___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
one note
source

Remarks:

Using MapPath with relative paths depends on the (int)EnableParentPaths value in the alp.application specified in sections managed by the ScriptGen content generator. If its value is 0 or the value not present MapPath will rise an exception if the passed parameter contains ".." characters - i.e. accesses parent paths.

also, is var "game" a char type in the DB?
if it is then you should enclose it in ' ' in this line

Set rs = Conn.Execute("SELECT [ID], [FileName] FROM NESgames WHERE [ID] = " & game)

where does objRec(""filename"") come in or more so objRec

I think you mean rs("filename")

quotes are not doubled in rs pointers. they are name qualifiers in the recordset so they have no string values in the build.

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
Thanks The problem im having lies in this line of code

Response.Write("<applet code = NESCafeApplet archive=""NESCafe056.jar"" width =256 height =240>
<param name=ROMFILE value=""games/"" &objRec("filename")> <param name=LIGHTGUN value=""false"">
<param name=SOUND value=""true"">
<param name=LOADSTATE value=""""> </applet>")

In the third line i would like to call the field "filename" from the database It just writes &objRec("filename") instead of the value i appreciate the help i apologize that i am not YET as profficient at writing script as you would prefer but ask your assistance again
 
you need to tear this line down and build it instead of a one liner. You're digging your own syntax grave with that method of programming.
it's long and really not getting formatted to the specs it needs to be

quotes need to be around ALL html tag attributes first off.
e.g.
code="NESCafeApplet" or code='NESCafeApplet'

use variables to help build the tags for you

for example

Dim myTag1
--first tag you need

myTag1 = "<applet code='NESCafeApplet' archive='NESCafe056.jar' width='256' height='240'>"
--next tag
Dim myTag2
myTag2 = "<param name='ROMFILE' value=" & Chr(34) & "games/" & rs("FileName") & Chr(34) & ">"

Chr(34) is the character ent for "

and so on..

___________________________________________________________________

onpnt.com
SELECT * FROM programmers WHERE clue > 0
(0 row(s) affected) -->faq333-3811

 
Yeah I agree, don't response.write all that stuff in one line.

In fact, there is only one variable in that whole thing... might as well re-write it like this:
Code:
<%
If Not rs.eof Then
%>
  <applet code    = 'NESCafeApplet' 
          archive = 'NESCafe056.jar'
          width   = '256'
          height  = '240'> 

    <param name = 'ROMFILE'   value = 'games/<%= objRec("filename")%>'> 
    <param name = 'LIGHTGUN'  value = 'false'> 
    <param name = 'SOUND'     value = 'true'> 
    <param name = 'LOADSTATE' value = ''> 
  </applet>
<%
End If
%>

Whitespace is your friend...
 
Thanks everybody you have all benn very helpful I have gotten it up and running thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top