I have an ASP form with a selection box populated via an SQL table. Some of the options have a section of text at the end of the string which I need to delete before the data is passed to the next page.
E.G. If the string from the dataase reads Extorsion e.g. illegal emails requiring payment. Then I need the data from the form field, being POST'd to the next form to just be 'Extorsion', not the 'e.g. illegal emails requiring payment.' I suspect it has something to do with strdelete or strwhere, but i've had no real experience with these commands. As each result will have the 'e.g. Unrequired data' it will be everything before th e.g. which I need to keep. I hope this is clear??? :rolleyes:, but you know when you have it in your head but can't explain ;) Thanx. Rik. |
Can't you just do something like...
newstring = Left$(oldstring, InStr(oldstring, "e.g.")) |
Will that delete everything after the 'e.g.' including the 'e.g.'??
|
yeah.. will create a new string with everything before the e.g.
|
Cheers :)
|
Little problem,
I have a variable 'threat1=request.form("threat")' which holds the data 'Extorsion e.g. illegal emails requiring payment.' I've used your code as follows: 'threat = Left$(threat1, InStr(threat1, "e.g."))' to hopefully pass the variable 'threat' to the next page without the e.g. illegal emails requiring payment.' When I submit the form it errors: Error Type: Microsoft VBScript compilation (0x800A0408) Invalid character /new_cit/risk/vulnerabilities/vulnerabilities1.asp, line 29, column 13' I take the $ out of the code and it passes 'Capacity Overload e' as the edited variable. It won't delete the final e, any ideas?? |
Adding a space to "e.g" worked for me: InStr(threat1, " e.g."))
Leaves a space though so just trim it: trim(InStr(threat1, " e.g."))) I've never seen $ used in VBScript, just PHP, Perl etc. |
Sorry to be a pain, but some of the options don't have the 'e.g.' at the end, so if you select one that doesn't at the moment it deletes everthing. How can I check to see if e.g. exists in the string and then delete the data if it does.
:) thanx. |
Can you not separate the content into a new table? i.e. have a new table with all the e.g. bits in, then just link them together when doing the initial recordset for the form.
Otherwise, just do an If(Instr(e.g.))= true then delete else, dont delete, end if etc Cant be ased typing full syntax, but you get the drift. :) |
Could someone help me with the full syntax. I'm not very familiar with this. :rolleyes:
|
IF InStr(threat1," e.g. ")= True THEN strThreat1 = Left$(threat1, InStr(threat1, " e.g.")) ELSE strThreat1 = threat1 END IF |
Shouldn't it be
IF INSTR(threat1," e.g. ")>0 THEN 'IT'S THERE ELSE 'IT'S NOT END IF ? |
Possibly - didnt test it, just wrote it :D
Could also be blah blah = 1 as well. Just test all three possibilities |
That's it Fosters :D - cheers!
Thanx DW, Adrian & Rob. :D |
All times are GMT +1. The time now is 05:36 AM. |
© 2024 MH Sub I, LLC dba Internet Brands