View Full Version : only first word of record displayed


emartel
04-06-2006, 05:25 AM
Hi there,
on a website Im designing, i have a searchable shop which is populated from an access db. You click on a thumbnail image in the shop and it gives you more details about the item on another page; this is done using the form method post action, and the extra details are stored in a hidden tex box on the main shop page and posted to the second page on click.
Only, on the page it posts to, it only displays the first word of the extra details (ie: everything up until the first space).
A way round it is to enter &nbsp; (ie: " this&nbsp;is&nbsp;my&nbsp;data ") in place of every space in the cell, but obviously this is not ideal. I've tried sticking the data between <p> tags too, and that didn't work.

I would really appreciate it if anyone could help me with this!

dan-cat
04-06-2006, 05:38 AM
posted to the second page on click.

How is this done? via a querystring? Are you using asp.net or asp?

emartel
04-06-2006, 06:12 AM
Hi,
no, its in a "form method=post action=" set in html and asp:
the data that is in the hidden fields below is only displayed on the form it posts to (moredetails2.asp), but it only dissplaays the first word of that data:

do until rs.EOF
response.write("<tr align=center>")
Response.write("<td align=right valign=center bgcolor=#bbbbbb>")
Response.write("<form method=post action=MoreDetails2.asp><p><input type=hidden name=LongDesc value=" & rs.Fields("LongDesc")& ">" & "</p>")
Response.write("<input type=hidden size=50 name=price value=" & rs.fields("price") & ">")
Response.write("<input type=hidden size=50 name=imageloc value=" & rs.fields("imageloc") & ">")
Response.write("<input type=hidden size=50 name=glassname value=" & rs.fields("itemname") & ">")

dan-cat
04-06-2006, 06:31 AM
I've just tested this with the following HTML...

<form id="Form1" method="post" action="test2.aspx">
<INPUT type="hidden" value="my Test Value" id="txtTest" name="txtTest"><INPUT type="submit" value="Submit">
</form>

...and it worked fine. Maybe it is the size value pair that is trimming your string?

emartel
04-06-2006, 06:49 AM
Hi, I'm afraid that's not it
I think the problem comes from the fact that the hidden value is stored in the database; if I change the input type to a text box, it still only shows up to the first space.
It cant be the length restriction (unnecessary as it is), as if I typed in "my&nbsp;test&nbsp;value" instead of "my test value" into the database field, it would display the text normally (as "my test value"). That led me to think that I had to put <p> or <tr> tags around it, but that didn't work, nor did "%>My test value<%"

thanks anyhow,

dan-cat
04-06-2006, 06:59 AM
Try hardcoding a hidden input control like I did and see if that works.

If so then compare the html of your response.write control to the hard-coded one. To see if there is any difference...

emartel
04-06-2006, 07:09 AM
Hi, thanks.
right,
I did that, giving it the value 'my test value' and it only displayed up until the space. entering 'my&nbsp;Test&nbsp;Value' as the value brings up 'my test value' as the response.

dan-cat
04-06-2006, 07:16 AM
Hi, thanks.
right,
I did that, giving it the value 'my test value' and it only displayed up until the space. entering 'my&nbsp;Test&nbsp;Value' as the value brings up 'my test value' as the response.

ok that weird - 'cos it worked for me.

What is the asp code in the second form that you are using to pull the data from this hidden field?

emartel
04-06-2006, 07:22 AM
Yeah, the thing is tho' that mine are inside 'Response.write ("' and then the html. Apart from that fact, i's the same principle as Im using on jmail forms and the like elsewhere.
The code that retrieves the values is:

Response.write ("<tr>")
Response.write ("<td align=center><font face=times new roman size=5 color=#000000><b>" & Request.form("itemname")& "</b></font></td></tr>")
Response.write ("<tr><td align=center><img src=images/stock/shop2/" & Request.form("imageloc") & " alt=" & Request.form("itemname") & "&nbsp;-&nbsp;" & Request.form("price") & "></td></tr>")
Response.write ("<tr><td width=50% align=center><br>" & Request.form("longdesc") & "</td></tr>")
Response.write ("<tr><td align=center><br><b>" & Request.form("price")& "</b></td></tr>")

dan-cat
04-06-2006, 07:47 AM
Response.write ("<tr>")
Response.write ("<td align=center><font face=times new roman size=5 color=#000000><b>" & Request.form("itemname")& "</b></font></td></tr>")
Response.write ("<tr><td align=center><img src=images/stock/shop2/" & Request.form("imageloc") & " alt=" & Request.form("itemname") & "&nbsp;-&nbsp;" & Request.form("price") & "></td></tr>")
Response.write ("<tr><td width=50% align=center><br>" & Request.form("longdesc") & "</td></tr>")
Response.write ("<tr><td align=center><br><b>" & Request.form("price")& "</b></td></tr>")

Ok its to do with your IMG tag - you haven't enclosed the elements of your IMG tag with quotation marks. So when a space occurs it thinks that is the end of the element.


Should be something more like...

<img src='images/stock/shop2/" & Request.form("imageloc") & '" alt='" & Request.form("itemname") & "&nbsp;-&nbsp;" & Request.form("price") & "'>

emartel
04-06-2006, 07:57 AM
Hi, I kind of see wht you mean, and Ill have to play around with it and see if I can get it to work.
thank you very much for your help !!

emartel
04-07-2006, 01:41 AM
I see, so the apostrophe has to replace the quote mark.
excellent,
thanksvery much!!