Results 1 to 22 of 22

Thread: another annoying quote problem

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    Here is another problem that I think is related to quotes. Here, the receiving page only gets the first part of the value (up to the first space, and the rest is truncated). I had a similar problem recently, and it turned out that I was missing some quotes. But I can't find it here. Help again, por favor?
    Code:
    <%
    	response.write "<input type=" & chr(13) & "hidden" & chr(13)
    	response.write " name=" & chr(13) & "facility" & chr(13)
    	response.write " value=" 
    	If IsAdmin = True Then
    		response.write chr(13) & cmbFacility & chr(13)
    	Else
    		response.write chr(13) & Facility & chr(13)
    	End If
    
    	response.write ">"
    %>

  2. #2
    bubba
    Guest
    Add quotes around the values, when you response.write, you need to double-up the quotes.

    Something similar to this:

    Code:
    <%
    	response.write "<input type= ""hidden"" name= ""facility""	
    
    response.write " value= """ 
    	If IsAdmin = True Then
    		response.write  cmbFacility
    	Else
    		response.write Facility 
    	End If
    
    	response.write """>"
    %>

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    bubba thanks for the try, but that gives me a value of a comma then a space. In the receiving page, I use that value to construct an SQL statement, like this
    Code:
    mySQL = "Select ROW_ID From Facility_Information Where FAC_NAME = '" & request.form("facility") & "'"
    and with your code it comes out

    Select ROW_ID From Facility_Information Where FAC_NAME = ', '

  4. #4
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    When I use response.write I include a single quote where I would use a double in HTML such as:
    Code:
    <%
    response.write "<input type='hidden' name='facility' value='" 
    If IsAdmin = True Then
         response.write  cmbFacility
    Else
         response.write Facility
    End If
    
    response.write "'>"
    %>
    I don't know if it will solve your problem but you can try.

  5. #5
    bubba
    Guest

    As I said: Something similar to this

    You need to play with the code, but using double and sometimes triple double quotes is the way to do it. using the single quotes as dcarlson said works -- but there could be other problem arising out of this if the data contains single quotes.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Angry

    Guys thanks for all of the help. I tried the double quotes, and it works for the variable value Facility. But for the select box cmbFacility, even with the single, double, or triple quotes it is STILL truncating values... anyone have ANY idea why?!?
    Last edited by DrewDog_21; Apr 6th, 2001 at 10:45 AM.

  7. #7
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Are you sure it's a quote problem?

    How about:
    Code:
    If IsAdmin = True Then
         response.write  Replace(cmbFacility, "'", "''")
    Else
         response.write Replace(Facility, "'", "''")
    End If
    Also on the other page try a response.write request.form("facility") to see what you have in there when it gets to the other page.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    no, I am not sure that it is a quote problem now. And I am about to jump out the damn window since I have been working on this one stupid problem for 3 hours. There are no single quotes anywhere in the select box. And response.write request.form("facility") brings up a blank value now. About an hour ago it at least showed a truncated string, so i seem to be going in the wrong direction...

  9. #9
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Can you post your full code for the page?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    sure, no problem

    I'll save both pages as text files and attach them. AddCensus is the calling page and ConfirmCensus is the receiving page.
    Attached Files Attached Files

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    here's the second file
    Attached Files Attached Files

  12. #12
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    I've never had problems using single quotes.
    Try this:
    Code:
    response.write "<b>Select Facility: </b></td><td><SELECT NAME='cmbFacility' SIZE=1 DEFAULT=True>"
    Also:
    Code:
    <% 
    response.write "<input type='hidden' name='facility'" 
    response.write " value='" 
    
    If IsAdmin = True Then 
         response.write cmbFacility
    Else 
         response.write Facility 
    End If 
    response.write "'>"
    %>
    For you to have a value for cmdFacility you need to have a default value selected in the box. If nothing is selected when your page loads cmbFacility will be blank.

    I think...

  13. #13

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374
    cmbFacility defaults to the first value. I tried what you suggested, but it does the same thing. Thanks for trying, though, I appreciate it

  14. #14
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Which page does response.write request.form("Facility") return nothing?

  15. #15
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Sorry, stupid question.

  16. #16

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Unhappy

    It returns it from the request command on the page ConfirmCensus.asp And for some reason I can't reference the combo box in AddCensus.asp from the page ConfirmCensus.asp, because it truncates everything after the first space still (see my other post)
    http://forums.vb-world.net/showthrea...threadid=66402

  17. #17
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Ok maybe another solution
    Code:
    If IsAdmin = True Then 'user is in administrative group because no facility code was found
    	response.write "<tr><td>"
    	response.write "<b>Select Facility: </b></td><td><SELECT NAME='Facility' SIZE=1 DEFAULT=True>"
    	rsFacility.MoveFirst
    	Do While Not rsFacility.EOF  'define the ListBox options
    		response.write "<OPTION VALUE=" & rsFacility("FAC_NAME") & ">" & rsFacility("FAC_NAME")
    		rsFacility.MoveNext
    	Loop
    	response.write "</SELECT></td></tr>"
    else
    	response.write "<input type='hidden' name='facility'" 
    	response.write " value='" & Facility & "'>"
    End If
    This way the administrator can chose the facility and everyone else is stuck with the hidden value

  18. #18
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    You also only have to check for request.form("facility") on the receiving page.

  19. #19
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    Sorry, I was barking up the wrong tree.

    I've managed to recreate what is happening. I usually use the get method of sending information through forms.
    Code:
    <form action="test2.asp" method="GET" id="frmSubmit">
    And use request.querystring("Facility") to retreive the value.

    I'll see if I can get it working.

  20. #20

    Thread Starter
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Columbia, SC USA
    Posts
    374

    Smile FINALLY!

    dcarlson and company, thanks so much for hanging with me here.

    For the curious, here was the final solution:
    I tried several different methods, including always using a hidden input box, using one only if the user was not an administrator, and using the QueryString. Everything that I tried either did not pass anything or only passed part of the string.

    dCarlson's final suggestion worked, save one thing: the line
    Code:
    response.write "<OPTION VALUE=" & rsFacility("FAC_NAME") & ">" & rsFacility("FAC_NAME")
    wrote only the string to the first space and then truncated the rest, as did several other things that I tried. The line should be
    Code:
    response.write "<OPTION VALUE='" & rsFacility("FAC_NAME") & "'>" & rsFacility("FAC_NAME")
    (note the added single quotes around '" & rsFacility("FAC_NAME") & "')

    Now I can FINALLY reference the hidden text box if the user is not an adminstrator, or the select box if the user is an administrator.

    Thank you guys SOOO much! I love a good challenge and all, but this drove me crazy!

  21. #21
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    SOLUTION!!!

    You need single quotes before and after the facility names.
    Code:
    response.write "<OPTION VALUE='" & rsFacility("FAC_NAME") & "'>" & rsFacility("FAC_NAME")
    Sorry for steering you in the wrong direction but this should solve it.

  22. #22
    Hyperactive Member
    Join Date
    Apr 2000
    Location
    Sudbury, Ontario, Canada
    Posts
    274
    You beat me to the post.

    Good stuff.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width