Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 18th, 2009, 12:18 PM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Text field not displaying all data from database cell

Hi,

I am retrieving a string from an access db cell and displaying it in a textbox, however the string cuts off after the first word.

How can I display the whole string?

code:

if objRS("signage")<>"ON" then response.write "<input style=display:none type=text name=signagetb / size=30 value=" & objRS("signagetb") & ">"%>

I can use (server.urlencode(objRS("signagetb"))) but it brings up the string with "+" and "%"

Many thanks

Ronny
 
Old June 18th, 2009, 03:07 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Has nothing to do with ASP, you know.

Try this as an HTML page:
Code:
<html><body>
<form>
<input name=whatever value=now is the time to come to>
</form>
</body></html>
What do you see??

Yep. As expected.

*NOW* try this:
Code:
<html><body>
<form>
<input name="whatever" value="now is the time to come to">
</form>
</body></html>
Properties in HTML *should* ALWAYS have quotes around them.

So:
Code:
<%
if objRS("signage")<>"ON" then 
    response.write "<input style=""display:none"" type=""text"" name=""signagetb"" " _
                & "  size=""30"" value=""" & objRS("signagetb") & """>"
end if
%>
But that's a really ugly set of code, isn't it? Try to AVOID using Response.Write to create more than the minimal amount of HTML you need.

Try this, instead:
Code:
<%
if objRS("signage")<>"ON" then 
%>
    <input style="display:none" type="text" name="signagetb" 
           size="30" value="<%=objRS("signagetb")%>">
<% end if %>
 
Old June 19th, 2009, 07:08 AM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I have altered all my code to replicate yours however I now receive the error:

"

Microsoft VBScript runtime error '800a01c2' Wrong number of arguments or invalid property assignment
"

Any idea what I doing wrong? All the onclick sections appear to have the same field names as their corresponding checkboxes.

Basically I want the form to appear as the user left it last - i.e. have the checkboxes which they checked still checked and the text fields displaying the text they entered.

The error refers to line 615 which is amongst the code below. I have highlighted the line which seems pretty innocuous.

Thanks

<tr>
<
td width="125%" height="21" bgcolor="#FFFFFF"
style="
border-left: 0px none; border-right: 1px none; border-top: 1px solid rgb(192,192,192)"><font
face="Arial">What additional measures are required to control the risk? <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<
a href="new_page_1.htm">info</a></small></font></td>
<
td width="38%" height="21" bgcolor="#FFFFFF"
style="
border-left: 0px none; border-right: 1px none; border-top: 1px solid rgb(192,192,192)"
colspan="
3"><font face="Arial"><% if objRS("information")="ON" then %><input type="checkbox" name="information"
onclick="
form.info_tb.style.display=checked?'':'none'" / value="ON" checked><%end if%> <%If objRS("information")<>"ON" then%> <input
type="checkbox" name="information" onclick="form.info_tb.style.display=checked?'':'none'"
/ value="
ON"><%end if%> Information</font><p><font face="Arial"><%if objRS("information")="ON" then %><input style="display:none"
type="
text" name="info_tb" / size="30" value="<%objRS("info_tb")%>"><%end if%> <%if objRS("information")<>"ON" then%><input
style="display:none" type="text" name="info_tb" / size="30" value="<%=objRS("info_tb")%>"><%end if%></font></td>
<
td width="80%" height="21" bgcolor="#FFFFFF" LINE 615!!!!
style="
border-left: 0px none; border-right: 1px none; border-top: 1px solid rgb(192,192,192)"><font
face="Arial"><% if objRS("instruction")="ON" then%><input type="checkbox" name="instruction"
onclick="
form.instructiontb.style.display=checked?'':'none'" / value="ON" checked><%end if%> <%If objRS("instruction")<>"ON" then %><input
type="checkbox" name="instruction"
onclick="
form.instructiontb.style.display=checked?'':'none'" / value="ON"><%end if%> Instruction</font><p><font
face="Arial"><%if objRS("instruction")="ON" then%><input style="text" type="text" name="instructiontb" / size="30"
value="
<%objRS("instructiontb")%>"><%end if%> <%if objRS("instruction")<>"ON" then %><input style="display:none" type="text"
name="
instructiontb" / size="30" value="<%objRS("instructiontb")%>"><%end if%></font></td>
<
/tr>
 
Old June 19th, 2009, 07:12 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I don't see it, but I sure see an opportunity to rewrite that code to be a LOT clearer and a lot shorter.

First of all, though, can you explain what the / character is for in all those HTML fields?? Such as:
Code:
...name="info_tb" / size="30"...
???? That's an illegal character, so far as I can see. Zap them all.

Now a rewrite.
Code:
<style>
td.CBCell { height: 21px; background-color: white;
            border-left: 0px none; border-right: 1px none; border-top: 1px solid rgb(192,192,192);
            font-family: arial;
          }
</style>

<td class="CBCell" colspan="3" style="width: 38%;">
<% 
If objRS("information")="ON" then 
    chk = "checked"
    display = ""
Eles
    chk = ""
    display = " style=""display: none;"" 
End If
%>
    <input type="checkbox" name="information" <%=chk%>
           onclick="form.info_tb.style.display=checked?'':'none'" value="ON" >
    Information
    <p>
    <input <%=display%> type="text" name="info_tb" 
           size="30" value="<%objRS("info_tb")%>">
</td>
<td class="CBCell" style="width: 80%;">
<% 
If objRS("instruction")="ON" then 
    chk = "checked"
    display = ""
Eles
    chk = ""
    display = " style=""display: none;"" 
End If
%>
    <input type="checkbox" name="instruction" <%=chk%>
           onclick="form.instructiontb.style.display=checked?'':'none'" value="ON" >
    Instruction
    <p>
    <input <%=display%> type="text" name="instructiontb" 
           size="30" value="<%objRS("instructiontb")%>">
</td>
Ehhh..the more I look at your code the more I think that the line number being reported is bogus.

If you do a VIEW-->>SOURCE on the page, where does the HTML cut off at?
 
Old June 22nd, 2009, 04:52 AM
Authorized User
 
Join Date: Mar 2004
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I think I resolved have the issue by added equals signs before the objRS("..."). Thank you for your help, particularly with the lesson on quoting HTML. I also took your advice and saw where the HTML cuts off.

new code:

<tr>
<
td width="125%" height="21" bgcolor="#FFFFFF"
style="
border-left: 0px none; border-right: 1px none; border-top: 1px solid rgb(192,192,192)"><font
face="Arial">What additional measures are required to control the risk? <small>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<
a href="new_page_1.htm">info</a></small></font></td>
<
td width="38%" height="21" bgcolor="#FFFFFF"
style="
border-left: 0px none; border-right: 1px none; border-top: 1px solid rgb(192,192,192)"
colspan="
3"><font face="Arial"><% if objRS("information")="ON" then %><input type="checkbox" name="information"
onclick="
form.info_tb.style.display=checked?'':'none'" / value="ON" checked><%end if%> <%If objRS("information")<>"ON" then%> <input
type="checkbox" name="information" onclick="form.info_tb.style.display=checked?'':'none'"
/ value="
ON"><%end if%> Information</font><p><font face="Arial"><%if objRS("information")="ON" then %><input style="text" type="text"
name="
info_tb" / size="30" value="<%=objRS("info_tb")%>"><%end if%> <%if objRS("information")<>"ON" then%><input style="display:none"
type="
text" name="info_tb" / size="30" value="<%=objRS("info_tb")%>"><%end if%></font></td>
<
td width="80%" height="21" bgcolor="#FFFFFF"
style="
border-left: 0px none; border-right: 1px none; border-top: 1px solid rgb(192,192,192)"><font
face="Arial"><% if objRS("instruction")="ON" then%><input type="checkbox" name="instruction"
onclick="
form.instructiontb.style.display=checked?'':'none'" / value="ON" checked><%end if%> <%If objRS("instruction")<>"ON" then %><input
type="checkbox" name="instruction"
onclick="
form.instructiontb.style.display=checked?'':'none'" / value="ON"><%end if%> Instruction</font><p><font
face="Arial"><%if objRS("instruction")="ON" then%><input style="text" type="text" name="instructiontb" / size="30"
value="
<%=objRS("instructiontb")%>"><%end if%> <%if objRS("instruction")<>"ON" then %><input style="display:none" type="text"
name="
instructiontb" / size="30" value="<%=objRS("instructiontb")%>"><%end if%></font></td>
<
/tr>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Displaying data from access database [email protected] Classic ASP Basics 1 January 24th, 2006 06:35 PM
Displaying data from a database mrideout BOOK: Beginning ASP.NET 1.0 0 August 13th, 2004 02:13 PM
Displaying Data in TextBox From Database(Urgent) gadhiav ASP.NET 1.0 and 1.1 Basics 2 June 17th, 2004 12:20 AM
Displaying Data in Textbox from Database(URGENT) gadhiav Classic ASP Databases 1 June 16th, 2004 02:06 AM
Displaying text depending on the value of a field lguzman Access VBA 1 May 30th, 2004 06:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.