Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Singapore
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Problems with String manipulation in form processing

    Hi guys,

    i'm currently experiencing problems manipulating string data from the forms i've submitted. JScript user here.

    What i basically did was to create 2 ASP pages, i'll just name it page 'A' and 'B'.

    Page 'A' has a textfield called 'songTitle', while page 'B' uses the Request.Form("songTitle") method to retrieve out back the String back right?

    Due to the fact that i'll need to do some truncating using the strObj.split( ) method to delimit some of the crap underscores, etc etc in the songTitle attribute, but it turns out that the Request.Form method returns the String object as a read-only String.

    Any idea how i can get around this problem so that i can still manipulate the text?

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    UK
    Posts
    102
    Thanks
    0
    Thanked 0 Times in 0 Posts
    On page B declare a new variable,

    See this

    Code:
    <%
    dim songtitle
    songtitle = Request.Form("songTitle") 
    
    
    
    %>

    You now have a variable that you can play around with.

  • #3
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Singapore
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmmz .. i'd tried that in Jscript, but it doesn't seem to work for me

    here's what i did, a simple test if the text is still read-only;

    <%
    ...
    var title, newStr;
    title = Request.Form("hTitle");
    newStr = title.concat("concatTest");
    Response.Write("Keyed in Title is: " + newStr);
    ...
    %>



    The scripting engine gave me this as an error;

    Microsoft JScript runtime error '800a01b6'
    Object doesn't support this property or method



    Edited: oh, thanks for the vb scriptlet Leeus, it seems that when using vbscript, there's no read-only issues involved.
    but is there any way to tackle the problem in JScript? 'cause i've java as my programming background, and i'm much more comfy using Jscript as my primary language in ASP.
    Last edited by Kinokunya; 02-10-2003 at 03:12 AM.

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,030
    Thanks
    0
    Thanked 247 Times in 244 Posts
    I think you need to use the String constructor.
    <%
    ...
    var title, newStr;
    title = new String(Request.Form("hTitle"));
    newStr = title.concat("concatTest");
    Response.Write("Keyed in Title is: " + newStr);
    ...
    %>

  • #5
    New to the CF scene
    Join Date
    Feb 2003
    Location
    Singapore
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    woah glenngv YOU ARE a lifesaver!

    thank you!

    hmmz ... any roundabouts to do the same for retrieval of data from the database?

    can i manipulate the String datatypes the same way using the newString( ) method as mentioned above?

    i've remember reading somewhere in the text, that data returned from the RecordSet are treated as read-Only objects.

    An option would be to close the connection from the database, alter the result sets, re-establish the connection to database back to update the latter, but when i closed the connection to the DB, they returned an error result saying that resultSet is no longer valid.

    I know it may sound stupid in manner of my coding but ... *sigh*
    Last edited by Kinokunya; 02-10-2003 at 04:13 AM.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Like Glenn pointed out, since the data returned from a database apparently is a read-only object in JScript, you simply need to assign the result to a variable...

    You can't manipulate the database variable itself unless you update the database anyway, that even applies to VBScript - so you need to store it in a "container" which would be a variable.

    If you need to update the database itself, you'll need to use a SQL UPDATE statement.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,030
    Thanks
    0
    Thanked 247 Times in 244 Posts
    any instance of a class inherits all the properties and methods of that class. You should know that, you are a Java man.
    <%
    ...
    var title, newStr;
    title = new String(rsObj.Fields("hTitle"));
    newStr = title.concat("concatTest");
    Response.Write("Title is: " + newStr);
    ...
    %>

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Heh, that looks more like it.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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