How can I add date range to code below?

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 11 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
ihechi
Posts: 7
Last visit: Thu Apr 04, 2013 1:46 pm

How can I add date range to code below?

Post by ihechi »

Greetings Experts,


Currently, we have vbscript and .hta app with SQL Server as backend database.

Our users can search the database with firstname, or lastname, or both. This works very well.

Here is code snip:

Code: Select all

'Take care of sql injection tactics
SQL_query = "SELECT TOP 100 Name, Rel, Estno, dtfild, pub, doc_typet, btyp, bkno, disp, dispdt, PGNO FROM myTable WHERE NAME LIKE '%" & Replace(txtsrch.value, "'", "''") & "%' ORDER BY NAME "
Set rsData = conn.Execute(SQL_query)
Then the search param called txtsrch:

Code: Select all

<input type="text" name="txtsrch" size="43"></font></b>
<input id="Gobutton" type="button" language="vbscript" value="Go" />
I would like to modify the codes above to add date range.

This way, users will have 3 input boxes.

The current input box that allows users to search by lastname, firstname, or some characters

AND two additional input boxs to enter start date and end date.

The idea is users can still search by curren txtsrch or they can searvh by date range but not by BOTH.

Your assistance is truly appreciated.

--i--
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How can I add date range to code below?

Post by jvierra »

Hi ihechi,

You are asking for a lot. Why not just add the bits and post back with questions when you get stuck.

With what you have posted there is not really enough information to give you a simple answer.

I also don't think we want to get into writing custom solutions and doing custom designs. As a scripting forum we can answer questions about specific script problems.

We also do not know your database or what kind of date fields you have or how they are set up.

If you need help learning how to script I can point you at many resources. Let me know.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How can I add date range to code below?

Post by jvierra »

As a starter just copy and edit the input boxes to also allow the dates you want.
User avatar
ihechi
Posts: 7
Last visit: Thu Apr 04, 2013 1:46 pm

Re: How can I add date range to code below?

Post by ihechi »

Hi JVierra,

Thank you very much for your response.

I will get started as you instructed and post back with specific questions.


I have actually done this numerous times. My doubt here is because it involves .hta.

BTW: I have read a ton of solutions you have provided to lots of people.

Thanks a lot for your kindness.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How can I add date range to code below?

Post by jvierra »

Hi ihechi,

I am glad you liked some of my solutions. It is too bad the script center is not available anymore.

If you just carefully copy the bits as they are used currently you will get very close. I can then give you simple steps to get to the solution.

An HTA is not too much different from a VBScript.

If you have PrimalScript look at the snippets. I believe there are some examples.
User avatar
ihechi
Posts: 7
Last visit: Thu Apr 04, 2013 1:46 pm

Re: How can I add date range to code below?

Post by ihechi »

Ok, great.

I do have one question right off the back.

In asp, we use something like this to get form value:

andor = Request.Form("ANDOR")

I am using the following as an equivalence in .hta:

andor = ANDOR.value

Is that correct?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How can I add date range to code below?

Post by jvierra »

IN ASP and web based HTML sites the form is king becuse the request object knows the for objects by name.

In an HTA this is not as useful. If we use an ID for a control then VBSA can directly access teh controls properties by ID.

Assume the following:
VBScript Code
Double-click the code block to select all.
<input type="text" id="txtDate" />
We can now reference the contents in code like this:

txtDate.Value
Or

txtDate.style.color = "red"
This allows for a simple method of access and is usable during the processing of any event.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How can I add date range to code below?

Post by jvierra »

:idea: Attached is a ZIP containing numerous examples of how an HTA can be managed.
Attachments
HTASampler.zip
HTA Samples in a ZIP
(14.62 KiB) Downloaded 447 times
User avatar
ihechi
Posts: 7
Last visit: Thu Apr 04, 2013 1:46 pm

Re: How can I add date range to code below?

Post by ihechi »

Ok, thanks a lot.
User avatar
ihechi
Posts: 7
Last visit: Thu Apr 04, 2013 1:46 pm

Re: How can I add date range to code below?

Post by ihechi »

Ok, I am almost done with this but I am stuck on one issue.

How do I manage radio buttons?

I have the following radio buttons I am trying to use as WHERE clause.

Code: Select all

<input name="ANDOR" id="ANDOR" type=radio checked value="AND"> Match all
	   <input name="ANDOR" id="ANDOR" type=radio value="OR"> Match any
I have used this in my asp/vbscript like the following way:

Code: Select all

    ' first: Do we use AND or OR between clauses in the WHERE?
    AndOr = Request.Form("ANDOR")

    If casenum <> "" Then
        If where <> "" Then where = where & AndOr
        where = where & " CaseNumber LIKE '%" & Replace(casenum,"'","''") & "%'"
    End If


Right now, when I declare the ANDOR like this:

Code: Select all

AndOr = Request.Form("ANDOR")
, I get object an error.

How do I declare it in .hta?

That's the only issue I have left to resolve.
This topic is 11 years and 1 week old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked