473,396 Members | 2,090 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,396 software developers and data experts.

pass value from javascript to jsp or html??

Friends,

Plz tell me how to pass a value from javascript to html or jsp??

Sample code will be more helpful.

Thanks in Advance
Jan 2 '11 #1
5 5615
Dheeraj Joshi
1,123 Expert 1GB
You can try following.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. function () {
  3.      document.forms.myform.textfield.value = "some value";
  4. }
  5. </script>
  6.  
Regards
Dheeraj Joshi
Jan 3 '11 #2
Hi Dheeraj,

Thanks a lot for your reply. Will try that code.

Dude I am stuck with another problem can you please help?

I want to to connect to mysql database using jsp.
But I am getting an exception at line
Class.forName("com.mysql.jdbc.Driver");

I am not getting how to proceed. So plz help.

Can you send me a simple example on the same?
Jan 8 '11 #3
Dheeraj Joshi
1,123 Expert 1GB
You need the JDBC driver for data base connection. The error implies it can not find the driver in the location.

Set the class path properly.

Regards
Dheeraj Joshi
Jan 8 '11 #4
Dheeraj I didn't understand this piece of code you sent.

<script type="text/javascript">
function () {
document.forms.myform.textfield.value = "some value";
}
</script>

Actually I want to store a value present in Javascript to my jsp variable. How do I do that?

Thanks in Advance
Jan 9 '11 #5
Hi yadagereavinash,

First get to know the difference between javascript and JSP.
Javascript is a client side scripting language whereas JSP is a servr side programming language.
This means that your JSP is compiled and executed by the Server whereas your Javascript will be executed by the browser.
So whenever you run a program your JSP first gets compiled and the resulting output is made into an HTML document and sent to the browser where the browser understands the HTML and scripts and displays the result.
Thus it is difficult to assign the value of a Javascript variable to JSP.
But there is possibility to assign your JSP variable value to javascript with limitations.

As far as i have known i was not successful to assign JS variable to JSP.
I've even posted this question in many other forums but couldnt get proper reply.

Y cant u try something else for that like using AJAX or DHTML.

If you find a solution for this, kindly let me know so that i can correct myself.
Thanks and Regards,
RAKHI
Jan 22 '11 #6

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

Similar topics

13
by: Phil Powell | last post by:
I am having a potential PHP/Javascript/HTML conflict going on in my code that I simply can't resolve - been wracking my brain for a good hour over this one and have come up with no good solution. ...
1
by: Al | last post by:
Ref:how to pass value along with click of a button hi,I have created a form that has single button. as follow <asp:button id="btnCallfunction" runat="server" text="func_call" onclick="add_int" />...
3
by: john woo | last post by:
Hi in JSP, it's easy to pass value from java-variable to javascript-variable, like js_function(a) { a=<%java-class.A%> } I'm wondering how is the other way around? I tried
3
by: startsmart | last post by:
Hi This is first time to write and alse it is first time to show this site my problem is i need to pass value from any input type like text for example to hidden field I tried to make a...
0
by: kmithu | last post by:
Hey friends, I am making a calender control using javascript but I am not able to retrieve its value on my .aspx.cs coding page in asp.net2.0. My text box code is : <input type="text"...
4
by: IRC | last post by:
hey, i am pretty new on javascript as well as PHP, Hey, anyone can you help me, how to pass the javascript array value to php page......... i want to retrieve the values which are arrayed on...
1
by: cleary1981 | last post by:
Hi, I have a form where I wish to pass one variable onto the next php page using a form action submit <form action="designmode.php?proj_id=document.getElementById("proj_id_hidden").value"...
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
8
oll3i
by: oll3i | last post by:
I use netbeans 6.5 i know how to pass a value from a service to jsp page but i dont know how to pass a value from html form to a service? thank You
7
gskoli
by: gskoli | last post by:
I have created a gif based digital clock but problem is that it will show me the client side time . I am a perl developer so i am getting server time, i mean , i can fetch that time , to pass the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.