473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Recordset in Javascript

Hi Guys, thanks for your help yesterday, I've got one more question, then I
think I'm done for now,...

Is it possible to insert recordset data in a javascript, for instance I have
a javascript code that calculates the total price, depending on number of
units, currently what the code does is set the price like so -

if qty 1 then £99+VAT

if qty equall to or greater than 2 and equall to or less than 9 then price =
70+VAT calculate total qty by price = total price + VAT

if qty equall to or greater than 10 and equall to or less than 19 then price
= 55+VAT calculate total qty by price = total price + VAT

if qty equall to or greater thar 20 and equall to or less than 50 then price
= 35+VAT calculate total qty by price = total price + VAT

See below

if((numQty >= 1) && (numQty <=
1)){document.getElementById('divPrice').innerHTML = '£' + '99.00' + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' + Math.round(100*(99
* numQty))/100 + ' + VAT';
}
else if((numQty >= 2) && (numQty <=
9)){document.getElementById('divPrice').innerHTML = '£' + '70.00' + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' + Math.round(100*(70
* numQty))/100 + ' + VAT';
}
else if((numQty >= 10) && (numQty <=
19)){document.getElementById('divPrice').innerHTML = '£' + '55.00' + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' + Math.round(100*(55
* numQty))/100 + ' + VAT';
}
else if((numQty >= 20) && (numQty <=
50)){document.getElementById('divPrice').innerHTML = '£' + '35.00' + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' + Math.round(100*(35
* numQty))/100 + ' + VAT';
}

What I would like to do is very similar, however I have 1 price which is
variable and called from a recordset, so for instance lets call the price xx

So my javascript would need to be something like this -

If qty <= 10 price = xx multipled by qty = Total Price
If qty >=11 but <=20 (xx /.9) multipled by qty = Total Price
If qty >=21but <=40(xx /.75) multipled by qty = Total Price
If qty >=41but <=50(xx /.6) multipled by qty = Total Price

of course the code above mine also has this -

innerHTML = '£' + '70.00' + ' + VAT' etc, so again I would need to have
something like innerHTML = '£' + 'qty <= 10 price = xx multipled by qty =
Total Price/ qty..
Does anyone have any ideas?
can this be done?

Thanks Gurus
Jul 8 '08 #1
4 2680
GTN170777 wrote:
Hi Guys, thanks for your help yesterday, I've got one more question,
then I think I'm done for now,...

Is it possible to insert recordset data in a javascript,
Do you mean "javascript in client-side code" or "javascript in server-side
code"? Either scenario is possible.
for instance
I have a javascript code that calculates the total price, depending
on number of units, currently what the code does is set the price
like so -
<snip - not really relevant>
See below

if((numQty >= 1) && (numQty <=
1)){document.getElementById
OK, you have some client-side javascript that calculates a value.

<snip - not really relevant>
What I would like to do is very similar, however I have 1 price which
is variable and called from a recordset, so for instance lets call
the price xx
Is this a server-side recordset? If so, you must be using Response.Write
(<%= ... %>) to pass the values to the client-side code, correct?
>
Does anyone have any ideas?
can this be done?
So, assuming we are talking about a server-side recordset (which is no
longer in existence at the time your client-side script is running, by the
way) your question seems to be:

"Can I insert data into a server-side recordset using client-side code?"

The answer? Not directly.
Let's go back to basics: When an asp file is called from the server, it is
passed to asp.dll, which goes through the file, finding and executing any
server-side code found (code which is between the <5...%tags, or inside
<script runat="serverblocks), generating the html which is passed to the
client (the browser). As soon as all the html either contained in the file
or generated by the server-side code is passed to the client, it ends the
response and basically moves on to the next file. So, as I hinted at above,
any recordsets that were opened by the server-side code are no longer in
existence (unless the Save method was used to persist them to file on the
server) at the time in which client-side code runs.

So the continuation of the answer is: no server-side code can run using
client-side data unless that client-side data is submitted to the asp file
containing that server-side code.

Now, in case I have misinterpreted your post and you actually are opening a
recordset in your client-side code (in which case I would be flabbergasted
that you would need to ask the quetion), I will not go into any more detail
except to name various techniques for passing client-side data to
server-side code without unloading the client-side code from the browser to
load a new page - google should enable you to find a lot of information
about these technologies, post back here if google leaves any of your
questions unanswered:

1.Use an <imgelement, using your client-side code to set the src property
to the appropriate .asp file along with a querystring containing the data
you wish to pass to the server-side code
2. Use a frame or an iframe to load the asp file
3. Use XMLHTTP to submit the data to the asp file
4. Use JSON

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 8 '08 #2
Hi Bob,

Thanks for the responce, what I should have said is that the page calls the
recordset data on load, the only information in the recordset is the single
unit price, and this is te only variable here, the percentages in the
javascript remain the same, so what I'm really trying to do is calculate the
cost per qty of units based on the set price of one unit multiplied by the
percentage for the number of units.

So hopefully the example below is a little more understandable -

If Qty 1 then XX
If Qty >= 10 but <= 20 then Qty multipled by XX multiplied by 90%
If Qty >=21 but <= 39 then Qty multiplied by xx multiplied by 75%

The value xx has alreadt been called by the recordset..

The javascript in the original post does the calculation and displays the
result on the same page when a button is pressed.

Hope this gives you a little more insight into what I'm trying to achieve.

Thanks once again Bob

"Bob Barrows [MVP]" wrote:
GTN170777 wrote:
Hi Guys, thanks for your help yesterday, I've got one more question,
then I think I'm done for now,...

Is it possible to insert recordset data in a javascript,

Do you mean "javascript in client-side code" or "javascript in server-side
code"? Either scenario is possible.
for instance
I have a javascript code that calculates the total price, depending
on number of units, currently what the code does is set the price
like so -
<snip - not really relevant>
See below

if((numQty >= 1) && (numQty <=
1)){document.getElementById

OK, you have some client-side javascript that calculates a value.

<snip - not really relevant>
What I would like to do is very similar, however I have 1 price which
is variable and called from a recordset, so for instance lets call
the price xx

Is this a server-side recordset? If so, you must be using Response.Write
(<%= ... %>) to pass the values to the client-side code, correct?

Does anyone have any ideas?
can this be done?

So, assuming we are talking about a server-side recordset (which is no
longer in existence at the time your client-side script is running, by the
way) your question seems to be:

"Can I insert data into a server-side recordset using client-side code?"

The answer? Not directly.
Let's go back to basics: When an asp file is called from the server, it is
passed to asp.dll, which goes through the file, finding and executing any
server-side code found (code which is between the <5...%tags, or inside
<script runat="serverblocks), generating the html which is passed to the
client (the browser). As soon as all the html either contained in the file
or generated by the server-side code is passed to the client, it ends the
response and basically moves on to the next file. So, as I hinted at above,
any recordsets that were opened by the server-side code are no longer in
existence (unless the Save method was used to persist them to file on the
server) at the time in which client-side code runs.

So the continuation of the answer is: no server-side code can run using
client-side data unless that client-side data is submitted to the asp file
containing that server-side code.

Now, in case I have misinterpreted your post and you actually are opening a
recordset in your client-side code (in which case I would be flabbergasted
that you would need to ask the quetion), I will not go into any more detail
except to name various techniques for passing client-side data to
server-side code without unloading the client-side code from the browser to
load a new page - google should enable you to find a lot of information
about these technologies, post back here if google leaves any of your
questions unanswered:

1.Use an <imgelement, using your client-side code to set the src property
to the appropriate .asp file along with a querystring containing the data
you wish to pass to the server-side code
2. Use a frame or an iframe to load the asp file
3. Use XMLHTTP to submit the data to the asp file
4. Use JSON

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 8 '08 #3
Please go back and reread what I said, especially about distinguishing
between client-side and server-side code when you are explaining your
problem to us. In particular, study the part where I talk about the basics.

For example, when you say " ... the page calls the recordset data on load
...." I have no idea if you mean:

"A recordset is opened in server-side code ... "
or
"A recordset is opened in the body's onload event in client-side code ..."

Remember, javascript can be used in both server-side and client-side code.
Saying "the javascript" does not explain anything, unless you preface your
remarks to explain that when you say "the javascript" that you are actually
talking about the client-side code.

In any event, your clarification really adds nothing to your original
explanation and I really have nothing to add to what I originally posted.

GTN170777 wrote:
Hi Bob,

Thanks for the responce, what I should have said is that the page
calls the recordset data on load, the only information in the
recordset is the single unit price, and this is te only variable
here, the percentages in the javascript remain the same, so what I'm
really trying to do is calculate the cost per qty of units based on
the set price of one unit multiplied by the percentage for the number
of units.

So hopefully the example below is a little more understandable -

If Qty 1 then XX
If Qty >= 10 but <= 20 then Qty multipled by XX multiplied by 90%
If Qty >=21 but <= 39 then Qty multiplied by xx multiplied by 75%

The value xx has alreadt been called by the recordset..

The javascript in the original post does the calculation and displays
the result on the same page when a button is pressed.

Hope this gives you a little more insight into what I'm trying to
achieve.

Thanks once again Bob

"Bob Barrows [MVP]" wrote:
>GTN170777 wrote:
>>Hi Guys, thanks for your help yesterday, I've got one more question,
then I think I'm done for now,...

Is it possible to insert recordset data in a javascript,

Do you mean "javascript in client-side code" or "javascript in
server-side code"? Either scenario is possible.
>>for instance
I have a javascript code that calculates the total price, depending
on number of units, currently what the code does is set the price
like so -
<snip - not really relevant>
>>See below

if((numQty >= 1) && (numQty <=
1)){document.getElementById

OK, you have some client-side javascript that calculates a value.

<snip - not really relevant>
>>What I would like to do is very similar, however I have 1 price
which
is variable and called from a recordset, so for instance lets call
the price xx

Is this a server-side recordset? If so, you must be using
Response.Write (<%= ... %>) to pass the values to the client-side
code, correct?
>>>
Does anyone have any ideas?
can this be done?

So, assuming we are talking about a server-side recordset (which is
no longer in existence at the time your client-side script is
running, by the way) your question seems to be:

"Can I insert data into a server-side recordset using client-side
code?"

The answer? Not directly.
Let's go back to basics: When an asp file is called from the server,
it is passed to asp.dll, which goes through the file, finding and
executing any server-side code found (code which is between the
<5...%tags, or inside <script runat="serverblocks), generating
the html which is passed to the client (the browser). As soon as all
the html either contained in the file or generated by the
server-side code is passed to the client, it ends the response and
basically moves on to the next file. So, as I hinted at above, any
recordsets that were opened by the server-side code are no longer in
existence (unless the Save method was used to persist them to file
on the server) at the time in which client-side code runs.

So the continuation of the answer is: no server-side code can run
using client-side data unless that client-side data is submitted to
the asp file containing that server-side code.

Now, in case I have misinterpreted your post and you actually are
opening a recordset in your client-side code (in which case I would
be flabbergasted that you would need to ask the quetion), I will not
go into any more detail except to name various techniques for
passing client-side data to server-side code without unloading the
client-side code from the browser to load a new page - google should
enable you to find a lot of information about these technologies,
post back here if google leaves any of your questions unanswered:

1.Use an <imgelement, using your client-side code to set the src
property to the appropriate .asp file along with a querystring
containing the data you wish to pass to the server-side code
2. Use a frame or an iframe to load the asp file
3. Use XMLHTTP to submit the data to the asp file
4. Use JSON

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 8 '08 #4
Thanks for your input Bob, I've actually managed to do this now, by storing
the variable in a hidden object on a form and then using the following
javascript to process the form -

function OpenWin(url)
{
window.open(url,'win','scrollbars=1,status=0,resiz able=0,width=200,height=265');
}
function btnCalculate_onclick()
{
var numQty;
var adprice;

if (isNaN(document.frmClient.txtQty.value))
{
alert('Please enter a number for advert quantity.');
}
else
{
numQty = parseInt(document.frmClient.txtQty.value);
adprice = parseInt(document.frmClient.adprice.value);

if((numQty >= 1) && (numQty <= 1)){
document.getElementById('divPrice').innerHTML = '£' + adprice + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' +
Math.round(100*(adprice * numQty))/100 + ' + VAT';
} else if((numQty >= 2) && (numQty <= 10)){
document.getElementById('divPrice').innerHTML = '£' +
(Math.round(adprice * numQty)*.8)/numQty + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' +
Math.round(adprice * numQty)*.8 + ' + VAT';
} else if((numQty >= 11) && (numQty <= 20)){
document.getElementById('divPrice').innerHTML = '£' +
(Math.round(adprice * numQty)*.6)/numQty + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' +
Math.round(adprice * numQty)*.6 + ' + VAT';
} else if((numQty >= 21) && (numQty <= 50)){
document.getElementById('divPrice').innerHTML = '£' +
(Math.round(adprice * numQty)*.5)/numQty + ' + VAT';
document.getElementById('maindivPrice').innerHTML = '£' +
Math.round(adprice * numQty)*.5 + ' + VAT';
} else {
alert("Please contact us for more information.");
}
}
}

Works a treat.

all the best

"Bob Barrows [MVP]" wrote:
Please go back and reread what I said, especially about distinguishing
between client-side and server-side code when you are explaining your
problem to us. In particular, study the part where I talk about the basics.

For example, when you say " ... the page calls the recordset data on load
...." I have no idea if you mean:

"A recordset is opened in server-side code ... "
or
"A recordset is opened in the body's onload event in client-side code ..."

Remember, javascript can be used in both server-side and client-side code.
Saying "the javascript" does not explain anything, unless you preface your
remarks to explain that when you say "the javascript" that you are actually
talking about the client-side code.

In any event, your clarification really adds nothing to your original
explanation and I really have nothing to add to what I originally posted.

GTN170777 wrote:
Hi Bob,

Thanks for the responce, what I should have said is that the page
calls the recordset data on load, the only information in the
recordset is the single unit price, and this is te only variable
here, the percentages in the javascript remain the same, so what I'm
really trying to do is calculate the cost per qty of units based on
the set price of one unit multiplied by the percentage for the number
of units.

So hopefully the example below is a little more understandable -

If Qty 1 then XX
If Qty >= 10 but <= 20 then Qty multipled by XX multiplied by 90%
If Qty >=21 but <= 39 then Qty multiplied by xx multiplied by 75%

The value xx has alreadt been called by the recordset..

The javascript in the original post does the calculation and displays
the result on the same page when a button is pressed.

Hope this gives you a little more insight into what I'm trying to
achieve.

Thanks once again Bob

"Bob Barrows [MVP]" wrote:
GTN170777 wrote:
Hi Guys, thanks for your help yesterday, I've got one more question,
then I think I'm done for now,...

Is it possible to insert recordset data in a javascript,

Do you mean "javascript in client-side code" or "javascript in
server-side code"? Either scenario is possible.

for instance
I have a javascript code that calculates the total price, depending
on number of units, currently what the code does is set the price
like so -

<snip - not really relevant>

See below

if((numQty >= 1) && (numQty <=
1)){document.getElementById

OK, you have some client-side javascript that calculates a value.

<snip - not really relevant>

What I would like to do is very similar, however I have 1 price
which
is variable and called from a recordset, so for instance lets call
the price xx

Is this a server-side recordset? If so, you must be using
Response.Write (<%= ... %>) to pass the values to the client-side
code, correct?

Does anyone have any ideas?
can this be done?

So, assuming we are talking about a server-side recordset (which is
no longer in existence at the time your client-side script is
running, by the way) your question seems to be:

"Can I insert data into a server-side recordset using client-side
code?"

The answer? Not directly.
Let's go back to basics: When an asp file is called from the server,
it is passed to asp.dll, which goes through the file, finding and
executing any server-side code found (code which is between the
<5...%tags, or inside <script runat="serverblocks), generating
the html which is passed to the client (the browser). As soon as all
the html either contained in the file or generated by the
server-side code is passed to the client, it ends the response and
basically moves on to the next file. So, as I hinted at above, any
recordsets that were opened by the server-side code are no longer in
existence (unless the Save method was used to persist them to file
on the server) at the time in which client-side code runs.

So the continuation of the answer is: no server-side code can run
using client-side data unless that client-side data is submitted to
the asp file containing that server-side code.

Now, in case I have misinterpreted your post and you actually are
opening a recordset in your client-side code (in which case I would
be flabbergasted that you would need to ask the quetion), I will not
go into any more detail except to name various techniques for
passing client-side data to server-side code without unloading the
client-side code from the browser to load a new page - google should
enable you to find a lot of information about these technologies,
post back here if google leaves any of your questions unanswered:

1.Use an <imgelement, using your client-side code to set the src
property to the appropriate .asp file along with a querystring
containing the data you wish to pass to the server-side code
2. Use a frame or an iframe to load the asp file
3. Use XMLHTTP to submit the data to the asp file
4. Use JSON

HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 9 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Rob Meade | last post by:
Lo all, Ok - this is what I was aiming to do, and then I thought - naahhh, that cant be right! query database results to recordset results to array using GetRows update values in one column...
2
by: Kevin Shea | last post by:
I'm currently running into a problem with ie6 on a windows 2000 machine. I've developed a web application where the client, using JavaScript, opens up an ADODB.Recordset recordset and then reads...
27
by: Oscar | last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in an ASP page to another HTML-page. Is there someone who can provide me with a small sample or a link to see how this is...
2
by: Chris | last post by:
I am new to these forums and hope I am in the right place! I am working on an ASP (3.0) page that displays hotel data from a recordset in a table. In the last column of each row, I want to...
1
by: anniefs | last post by:
hi help me i m so much stuck int he code and i have no time .... i used ASP VBscipt and javascript functions with MS database javascript function add records in MS DB by using ASP vbscript...
2
by: wallconor | last post by:
Hi, I am having a problem using Dreamweaver CS3 standard recordset paging behavior. It doesn’t seem to work when I pass parameter values from a FORM on my search page, to the recordset on my...
2
by: Yaara Mac | last post by:
Hi all, I need some help with using recordset.bof / oef. I'm using HTML file to display XML records page by page. I need to disable the moveNext button once it reaches the end of the file...
16
by: haft | last post by:
I have posted this question on a javascript forum as it contains javascript code however it was believed to be an asp issue. The following head section javascript code contains the function...
1
by: shivasusan | last post by:
Hi Friends! Please Help me! How i can solve this error? Please explain me, what is the error and how to solve? Error Type: ADODB.Recordset (0x800A0E7D) The connection cannot be used to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.