Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Angry Unanswered: Not saving a + sign????

    I have a added two new fields to my website, where users will have the ability to enter any character from a standard keyboard.

    I will post my code so somebody could look at it,as it seems to be able to save every charc. but the + sign,don't know what is happening there

    I am using sql 2000

    Fields are DONATIONNUMBER and BLOODGROUP

    function SaveDetails()
    {
    var szRedirect

    if (window.thisForm.HospitalID.value == '' ||
    window.thisForm.EnteredMonth.value == '' ||
    window.thisForm.EnteredYear.value == '' ||
    window.thisForm.ProductID.value == '' ||
    window.thisForm.FateID.value == '' ||
    window.thisForm.UnitsDiscarded.value == '' ||
    window.thisForm.DonationNumbers.value == '' ||
    window.thisForm.BloodGroup.value == '' ||
    window.thisForm.CompiledBy.value == '' ||
    window.thisForm.DateCompleted.value == '')
    {
    window.alert("You must enter all the fields in order to submit the data! Partial details cannot be stored!");
    return
    }

    szRedirect = "HOSPITALID=" + escape(window.thisForm.HospitalID.value);
    szRedirect = szRedirect + "&ENTEREDMONTH=" + escape(window.thisForm.EnteredMonth.options(window .thisForm.EnteredMonth.selectedIndex).text + ' ' +
    window.thisForm.EnteredYear.options(window.thisFor m.EnteredYear.selectedIndex).text);
    szRedirect = szRedirect + "&PRODUCTID=" + escape(window.thisForm.ProductID.value);
    szRedirect = szRedirect + "&FATEID=" + escape(window.thisForm.FateID.value);
    szRedirect = szRedirect + "&UNITSDISCARDED=" + window.thisForm.UnitsDiscarded.value;
    szRedirect = szRedirect + "&COMPILEDBY=" + escape(window.thisForm.CompiledBy.value);
    szRedirect = szRedirect + "&DATECOMPLETED=" + window.thisForm.DateCompleted.value;
    szRedirect = szRedirect + "&DONATIONNUMBERS=" + escape(window.thisForm.DonationNumbers.value);
    szRedirect = szRedirect + "&BLOODGROUP=" + escape(window.thisForm.BloodGroup.value)
    window.navigate("Submit.asp?" + szRedirect);

    }

    ------------------------------------------------------------

    Call myCon.Execute ("INSERT INTO Bloodbank.dbo.Units (HospitalID, DateEntered, ProductID,FateID, UnitsDiscarded, DateCompleted, " & _
    "CompiledBy, DonationNumbers,BloodGroup) VALUES ( " & _
    BuildString(Request.queryString("HospitalID").item ) & "," & _
    BuildString(Request.QueryString("EnteredMonth").it em) & ", " & _
    BuildString(Request.QueryString("ProductID").item) & "," & _
    BuildString(Request.queryString("FateID").item) & "," & _
    Request.QueryString("UnitsDiscarded").item & ", GETDATE(), " & _
    BuildString(unescape(Request.QueryString("Compiled By").item)) & "," & _
    BuildString(unescape(Request.QueryString("Donation Numbers").item)) & "," & _
    BuildString(unescape(Request.QueryString("BloodGro up").item)) & ")")

    Call myCon.Close


    What am I doing wrong, or not doing at all?

    Thanks and regards

  2. #2
    Join Date
    Nov 2003
    Location
    Christchurch, New Zealand
    Posts
    1,618
    Is the + getting escaped out in your querystring perhaps and thus you lose it??

    Drop some debugging into you code to determine exactly where it gets lost.

  3. #3
    Join Date
    Jul 2003
    Location
    SoCal
    Posts
    721
    Quote Originally Posted by zobernjik
    szRedirect = szRedirect + "&DONATIONNUMBERS=" + escape(window.thisForm.DonationNumbers.value);
    szRedirect = szRedirect + "&BLOODGROUP=" + escape(window.thisForm.BloodGroup.value)
    Looks like your problems might be rooted in the "escape" function of JavaScript. The purpose of this function is to convert non-alphabetic characters to a hexidecimal code. A + sign would be converted to the value %2B.

    Is there a reason you're using JS to build a querystring instead of posting the values through the form? You could even use "GET" instead of "POST" in your form to convert the submission into a querystring automatically...

    edit
    I accidentally gave you the decimal value of 43 instead of the hex value of 2B...
    Last edited by Seppuku; 06-11-04 at 12:19.
    That which does not kill me postpones the inevitable.

Posting Permissions

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