www.webdeveloper.com
Results 1 to 5 of 5

Thread: reading string to db....

  1. #1
    Join Date
    Feb 2003
    Posts
    35

    reading string to db....

    in this line
    Response.Write "<td ><input type='text' size=20 name='add1' value= "&rs.fields("Address1")&"></td>"
    the rs.fields("Address1") reading only the first word till the space ....
    what i nees to write that it will read the all address with all the words in this field?

  2. #2
    Join Date
    Nov 2002
    Location
    Norwood, MA
    Posts
    186
    Hey!

    Something I know!! You should replace the " marks with "" marks whenever inside the Response.Write(" and "), that way the code sends out a quotation mark to be written out instead of thinking it's the end of the Response.Write statement.

    Hope I was clear!

    Natalia

  3. #3
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    hi,
    personally to avoid any confusion i usually assign the rescordset value to a variable before including in a resposne.write srting, like so:
    Code:
    <%
    myvariable = rs("fieldname")
    
    response.write "<td><input type='text' size=20 name='add1' value='"&myvaribale&"'><td>"
    %>
    Also in your code there is a syntax mistake you have missed out the ' and ' around the value part of your input tag.

    Code:
    Response.Write "<td ><input type='text' size=20 name='add1' value= '"&rs.fields("Address1")&"'></td>"
    hope this helps.
    ----------------------------------

  4. #4
    Join Date
    Feb 2003
    Posts
    35
    thank you for your answer i can't belive it is only a ''mistake...
    maybe u have a simple code that can help me with
    chackbox or radio it looks like after i chack or unchack it is not going into my db...and stay aas before...
    Response.Write "<td width='5%'><input type='radio' size= 10 name='mailing' value= '"&rs("mailingList")&"'></td>"

    and in the db
    If Request.form("mailing")="CHECKED" then
    rs("mailingList")= True
    else
    rs("mailingList")= False
    end if

  5. #5
    Join Date
    Jan 2003
    Location
    Dundee, Scotland
    Posts
    1,367
    Hi,
    here is an example of how i would do it:
    Code:
    <%
    '----- first request the hidden field to see if this is the first time the page has been displayed
    validate = request.form("validate")
    
    '-------Now set an if statement.  If the form has been submitted then do the validate else display the form---
    if validate = "yes" then
    '---------request the checkbox submitted. -----------------
    dim thecheckbox
    thecheckbox = request.form("checkbox")
    '---------i am just writing out the value of the check box, you will not need this in your final code.-------
    response.write thecheckbox
    '----now your yes/no feild should be set to no/false at the moment so you can either of the following----
    '---first way to do this-----------
    if thecheckbox = "True" then
    response.write "insert this to databse"
    SQL = "insert Into tblTableName (myyesnofield) values ('"&thecheckbox&"')"
    set InsertSet = youdatabase.Execute(sql)
    else
    response.write "do nothing"
    end if
    '-----second way if you need to insert regardless of the checkbox value then you need to do this.
    '-----you can't just insert nothing to the field so you will have to manualy set thecheckbox value to false if it wasn't checked
    if thecheckbox = "" then
     thecheckbox = "False"
    end if
    '-------now you can do your insert.  It doesn't matter if it was checked or not either a true or false will be inserted.
    '-------True will obviously set the yes/no field to checked.
    SQL = "insert Into tblTableName (myyesnofield) values ('"&thecheckbox&"')"
    youdatabase.Execute(sql)
    
    else
    %><form action="checkboxexample.asp" method="post">
    <input name="Checkbox" type="checkbox" value="True">
      Checkbox 1 <BR>
      <input name="Sumbit" type="submit" value="submit">
      <input name="validate" type="hidden" value="yes">
    </form>
    
    <%
    end if 
    %>
    ----------------------------------

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles