473,387 Members | 1,542 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,387 software developers and data experts.

Changing Client side JS to Server Side JS

Hi, I was wondering if I can get some help with changing client side javascript to server side javascript. I have a survey connected to an Enterprise Manager SQL database. My code works and the database is updated successfully but I get a warning message

"This Website uses a data provider that may be unsafe. If you trust the website click OK otherwise click cancel."

This warning happens twice which I understand one is to open the database and one is to insert data into it.

I do know serverside begins with

<%@ LANGUAGE = JavaScript%>

But I'm not sure how to take this code and adapt it to serverside javascript, and also where to place it within the asp file.

I've taken snippets of my code and placed it below.

Any help would be appreciated.

Kind regards
Expand|Select|Wrap|Line Numbers
  1.  
  2. // Find latest ID or default to 1 for first time
  3.           if (rs.eof) 
  4.           {
  5.            var    new_id = 1;
  6.         }
  7.         else
  8.         {
  9.            var new_id = rs(0) + 1;    
  10.         }
  11.  
  12. // Find Selected anser for Q1
  13.         for (var i=0; i < document.survey.q1.length; i++)
  14.            {
  15.                if (document.survey.q1[i].checked)
  16.               {
  17.                   var q1_ans = document.survey.q1[i].value;
  18.                   }
  19.            }
  20.  
  21. var email_ans    = document.survey.email.value.replace("'","''");
  22.         var feedback_ans = document.survey.feedback.value.replace("'","''");
  23.  
  24.         var strInsertSQL = "INSERT INTO SURVEY_RESULTS_TAB VALUES (" + new_id + ",'" + email_ans + "','" + 
  25.                              q1_ans + "','" + q2_ans + "','" + q3_ans + "','" + q4_ans + "','" + q5_ans + "','" + 
  26.                             q6_ans + "','" + q7_ans + "','" + q8_ans + "','" + q9_ans + "','" + feedback_ans + "')";
  27.  
  28.         adoConnection.Execute(strInsertSQL);
  29.  
  30.         rs.close();                        
  31.  
  32.         adoConnection.Close();
  33.  
  34.         document.body.style.cursor = "default";
  35.  
  36.         location.href = "thankyou.html";
  37.  
  38.     }
  39.  
  40.     //-->
  41.  
  42. </SCRIPT>
  43.  
  44.  
Expand|Select|Wrap|Line Numbers
  1. <form name=survey method=post onSubmit=survey_answers()>
  2.  
  3. <input name="q1" type="radio" value="VS">
  4.  
  5. <input name="q1" type="radio" value="S">
  6.  
  7. <input name="q1" type="radio" value="D">
  8.  
  9. <input name="q1" type="radio" value="VD">
  10.  
  11. <input name="q1" type="radio" value="NA" checked>
  12.  
  13.   <INPUT type=button value="Submit" onClick="survey_answers()"> 
  14. </form>
  15.  
Mar 19 '10 #1
4 1656
gits
5,390 Expert Mod 4TB
i'm not aware of such an approach ... the server doesn't know the values of form-elements without getting them transferred via a GET or POST ... so i would simply suggest to submit a form and process only the values serverside ... you cannot read them serverside from the client ...
Mar 20 '10 #2
Is it possible to give me an example of how I might do this using the code above?

Thanks
Mar 22 '10 #3
Hi, Just thought it would help if I attached the warning I get when I submit the form. This appears twice and this is what I am trying to get rid of.
Attached Images
File Type: jpg warning.jpg (8.6 KB, 129 views)
Mar 22 '10 #4
gits
5,390 Expert Mod 4TB
as far as i'm aware your code will only work in IE - and you asking how to process submitted form values serverside? ... this is quite basic and in this case you should ask in the appropriate serverside language forum ... ASP or JSP or whatever you want to use.
Mar 22 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Kathryn | last post by:
Hiya I have a problem with using some client side and server side scripting together in an ASP. I'm using VBScript. What I'm trying to achieve is this - - Page loads up and some server side...
5
by: martin | last post by:
I needed a way to display calculated, multiple, changing values (numerical sums) as users interacted with the page, and do this without going back to the server to load the page again. What I...
16
by: chris | last post by:
im new to javascript but slowly getting better what i want to do is have some text on the screen and when an event happens for example click a button the text would change to what i want. how...
3
by: Michael Eisenstadt | last post by:
What are the coding options for client-side image size changing? I want the viewer to be able to switch between two different sizes of the same image with his/her mouse. Thanks in advance for...
6
by: Ken Allen | last post by:
I am relatively new to .Net and C#, but I hav ebeen programing in other languages and done some COM work for a number of years. I am attempting to understand how to map an older program...
3
by: Jeremy Ames | last post by:
I have a form that contains two hidden values, among other controls. I was wondering, if I change these values in server script and immediately do a server.transfer, do these values get updated...
10
by: Bill | last post by:
In file FIRST.ASP, I've got <% Response.Redirect "SECOND.ASP" %> The redirect is happening, and I'm seeing the content from SECOND.ASP in the browser, but the URL in the browser is still...
6
by: Velislav | last post by:
Hi, I have a client script block, which is registered in my Page_Load. However a button may result in the need to change the script which I've registered. Obviously the OnClick event occurs...
1
by: T00ks | last post by:
The Background: I have data stored in an SQL Database, i'm using asp.net and c# to retrieve the data from the database and update the client side asyncronously (sp?). the behind code looks as...
10
by: Aaron Fude | last post by:
Hi, I have a webpage delivers, let's say, a pdf document. The page is password protected so itially it shows HTML, but when the user logs in the page is reloaded with...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...

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.