Skip to main content
Inspiring
March 2, 2007
Question

Can I open a recordset On Client Side Script?

  • March 2, 2007
  • 15 replies
  • 2440 views
Hi Guys,

On a form I have a client side VBscript thet checks the email addy a user has added into a text box in a form and if its in the array of values set in the script it gets refused. This works.....

I would like to adapt this a little if possible and make it so that instead of hardcoding the array values into the script, I would like to have the array values taken from a recordset because it will allow the user to add and delete bad domains via a form and not need to go into the page code to add to the array I have at the moment.

I have tried serval times to replace my array loop with a recordset while loop to get the badDomains from the field in the database but I just get script error on page in my task bar.

Can I open a recordset from a client side script?

Id apprecaiate eny thoughts on how I can do this.

Thanks again
Tag
This topic has been closed for replies.

15 replies

Tag2007Author
Inspiring
March 7, 2007
I just gave this a go and realised a problem I hadnt thought of?

I tried to do all this in the Client script when the user hits the submit button and calls the script and I when trying to connect to the database realised its on the server in a private directory??

So the client script is erroring out at the database connection level of my code as you can imagine..Im presuming its the database being on the server and it just cant see it or get to it from the browser?

Do I have to open the recordset server side first then call the array into the client script?

Any advice appreciated.
Thanks again
Tag
Tag2007Author
Inspiring
March 7, 2007
Thank you envision3d ,

Yes that seems like what im trying to do, I did presume that I would have to construct a string with delimiters etc to replace my current hard coded array but If I can do as you have suggested I can loop through all values in the recordset field I want to check without the need of constructing a string??

I will have a go at this now I have a bit more direction.
Thank you.
Tag
Inspiring
March 7, 2007
Maybe I didn't understand you problem exactly, but its seems that you are just trying to populate an array with values from a recordset in VBScript. This is very easy to do, maybe something similar to:

<%
dim myArray()
for x = 0 to rs.RecordCount
myArray(x) = rs.fields.item("restrictedEmail").value
next
%>

And now the array is populated with the data. Now when you do your check just loop through the array to compare the values.
Tag2007Author
Inspiring
March 7, 2007
Thank you for that Paul,

I wonder if you have an example you can point me to if possible as this sounds exactly what I need to do. Im a little unsure on how to get my returned recordset into my string array, my array is wriitten in this way Array("hotmail.com", "hotmail.co.uk") ......delimited with a comma as you mention.

Ive been searching the net for some info but have came up with everything but what I need.. ;-)

I have managed something similar using a little ajax but what your saying is more in line.

Many thanks
Tag
Inspiring
March 7, 2007
You can output any recordset information into an page array. All you need to
do is place the recordset at the point in the client script where you need
it to appear.

The most common way in which this causes problems, however is where you
specify a delimiter in the field (like a comma) and then you end up with one
right at the end of the list.

The way around this is to create a string variable, loop the records into
that first, and then use a command to remove the last character. Then you
call this variable in the client code

--
Paul Whitham
Certified Dreamweaver MX2004 Professional
Adobe Community Expert - Dreamweaver

Valleybiz Internet Design
www.valleybiz.net

"Tag2007" <webforumsuser@macromedia.com> wrote in message
news:es8tpu$2g0$1@forums.macromedia.com...
> Hi Guys,
>
> On a form I have a client side VBscript thet checks the email addy a user
> has
> added into a text box in a form and if its in the array of values set in
> the
> script it gets refused. This works.....
>
> I would like to adapt this a little if possible and make it so that
> instead of
> hardcoding the array values into the script, I would like to have the
> array
> values taken from a recordset because it will allow the user to add and
> delete
> bad domains via a form and not need to go into the page code to add to the
> array I have at the moment.
>
> I have tried serval times to replace my array loop with a recordset while
> loop
> to get the badDomains from the field in the database but I just get script
> error on page in my task bar.
>
> Can I open a recordset from a client side script?
>
> Id apprecaiate eny thoughts on how I can do this.
>
> Thanks again
> Tag
>