Solved

Get a javascript value into ASP without submit

Posted on 2010-08-25
14
779 Views
Last Modified: 2012-05-10
Good Day,

I have searched the site and must not be searching with the right terms as I have not found the answer so here goes.
I have a form that has a javascript prompt to get a value.  I need to get the value from the prompt and into ASP so I can run a query against one of the oracle tables.  I know the difference between javascript (client side) and ASP (server side) and I know the easiest way is to submit the form but I can't do that for reasons I won't go into.  Is there any other way to get that value from javascript and into ASP so the rest of the page can process?
0
Comment
Question by:thamilto0410
  • 6
  • 3
  • 3
  • +1
14 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 33525525
0
 
LVL 7

Expert Comment

by:Jonah11
ID: 33525527
This can be done using AJAX.  Here is an example page:

http://www.aspjax.com/

Hope that helps.  I can't give you any more specifiic advice without looking at code, but that link may be enough for you.
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 33526193
leakim971 or jonah11:  That helped tremendously.  Especially yours leakim971 as it was a little easier for me to understand.  I have incorporated and it is almost working.  Next question I would like the url for the ajax to be the same asp file and I am passing the value from the prompt as part of the url querystring but I don't see it.  Can I not just right it to the page so I can know it is coming back into the page?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33526511
Next question :

>I would like the url for the ajax to be the same asp file
Not a good idea. You will need in your code something like :

If this is a page request send html page
Else If this is an ajax call insert in database

It's not an usual way to use ajax. Most of time you have a script for and ajax call, something like : insertToOracle.asp
And you send a query as parameter for example

>Next question I would like the url for the ajax to be the same asp file
with GET method something like

xmlhttp.open("GET", "/path/to/insertToOracle.asp?query="+ encodeURI("INSERT INTO TABLE1 VALUES (1,5,6)"),true);
0
 
LVL 18

Expert Comment

by:Rajar Ahmed
ID: 33528503
Done exactly this . but on sql jst replace query statement . downloading d file .
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/ASP/Q_26411950.html?#a33467125
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 33529785
meeran03 and leakim971:  Thanks for your response.  Still need a little more help.  Maybe I need to give a few more details about what I am doing I think I have confused the situation.  I have an ASP form that queries the database and populates arrays for dropdowns or fills in elements on a form.  But the queries must know the case type.  Now the user chooses the case type in the very beginning of the process and clicks save and after that I get case type from the DB.  But I found some users selected case type and did not save they exited the form with the X in internet explorer so when the form reloads the queries cannot be called if there is no case type already in DB therefore the prompt.


meeran03 I don't need to query a database with the ajax.  leakim971 I understand that it is not wise to call the same page.  So if I need to capture the value from the javascript prompt and get it back to the original page how do I do that when it is an asp page being processed by the server.  Can I call another page (any page) and in this page set a session variable with the value from the prompt and if I did would that make it available to the original page.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:thamilto0410
ID: 33534008
I still need a little help.  I have found out the session variable in another file does work but what I don't understand is why one time it does and the next it does not.  It is almost like the next procedure is getting call faster (after it gets back to the original page) than the session variable is getting set .  Is this possible?
0
 
LVL 1

Accepted Solution

by:
thamilto0410 earned 500 total points
ID: 33543343
Never mind.  Figured out that I was trying to hard.  One professor from college always used to say KISS and now I understand.  To solve the problem I took 2 steps back and realized when the users queue loads with their current work there is a link to each form.  The form is where I need the above referenced value.  So when queue loads I check for the value needed at this point and if not there then prompt user then add the value to the link then load the form.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33543911
:)
0
 
LVL 7

Expert Comment

by:Jonah11
ID: 33558923
This is pretty rude.  A number of experts have spent time answering, and have in fact offered solutions to the original problem posted.  The OP should award points for the help and solution he received, not close the question because he realized he asked the wrong question to begin with.
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 33563035
Jonah11:  It is not rude when the suggestions made were incorporated into the application and still it did not provide the solution I needed.  I thought the point of this site was for experts to offer their expertise.  This expertise and assistance possibly resulting in a solution for individuals that still have a lot to learn. As I was incorporating the assistance offered into the application I asked for additional assistance and I don't see anywhere above where you jumped in the second time to help and now you want to call me rude?  Finally I did not close because I (and by the way I am a she) realized I had asked the wrong question.  I closed because the AJAX was not the solution.  I found the solution on my own and it turned out to be simpler than the call to AJAX.  I always am one to award points when a solution (even a partial solution) is offered.  Considering that is not the case here explain to me why I should award?
0
 
LVL 7

Expert Comment

by:Jonah11
ID: 33563112
Why should offer points?  Here's why (and I quote you): "leakim971 or jonah11:  That helped tremendously. "

And because posters here are offering their time for free, in exchange for the paltry reward of points, which cost you nothing to give.  

And because this was the question you originally asked: "Is there any other way to get that value from javascript and into ASP so the rest of the page can process?"  And that question was answered.  

I stand by my assessment of your rudeness, and I am done with your thread.  Go ahead and close it if it makes you feel better.
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 33563160
Except that if you noticed in the thread above your assistance was not the one that helped tremendously.  I said to start with I did not know what I was doing and in the thread I said leakim971's was the one that helped still it did not resolve the problem.  In addition I had to take it back out as AJAX was not what I needed.  Now I am done with you.  LEAKIM971 PLEASE chime in.  If I am being rude tell me so and I will award points to you AS YOU and not Jonah11 OFFERED THE MOST ASSISTANCE.  
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now