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.
User avatar
ihechi
Posts: 7
Joined: Mon Apr 01, 2013 10:52 am

How can I add date range to code below?

Post by ihechi » Mon Apr 01, 2013 11:02 am

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--

User avatar
jvierra
Posts: 13394
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Apr 01, 2013 11:44 am

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.

User avatar
jvierra
Posts: 13394
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Apr 01, 2013 11:48 am

As a starter just copy and edit the input boxes to also allow the dates you want.

User avatar
ihechi
Posts: 7
Joined: Mon Apr 01, 2013 10:52 am

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

Post by ihechi » Mon Apr 01, 2013 12:17 pm

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.

User avatar
jvierra
Posts: 13394
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Apr 01, 2013 12:31 pm

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
Joined: Mon Apr 01, 2013 10:52 am

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

Post by ihechi » Mon Apr 01, 2013 12:40 pm

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?

User avatar
jvierra
Posts: 13394
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Apr 01, 2013 1:23 pm

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.

User avatar
jvierra
Posts: 13394
Joined: Tue May 22, 2007 9:57 am
Contact:

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

Post by jvierra » Mon Apr 01, 2013 1:26 pm

: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 290 times

User avatar
ihechi
Posts: 7
Joined: Mon Apr 01, 2013 10:52 am

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

Post by ihechi » Mon Apr 01, 2013 1:35 pm

Ok, thanks a lot.

User avatar
ihechi
Posts: 7
Joined: Mon Apr 01, 2013 10:52 am

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

Post by ihechi » Thu Apr 04, 2013 9:22 am

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.

Locked