| | |
scriptlet in javascript
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Apr 2009
Posts: 17
Reputation:
Solved Threads: 0
hii..
I want to use a scriplet variable in javascript.
i used
<%! int i;>
<% i=0; %>
<input type="text" id="itemValue" onchange=changeValue('<%i%>')>
it works fine if i give alert(i) in
changeValue function.
Otherwise it gives error i is undefined.
Plz help me. I don't want to bother user by increasing one user click.
Plz help what is the reason ????
i m using struts 1.2
I want to use a scriplet variable in javascript.
i used
<%! int i;>
<% i=0; %>
<input type="text" id="itemValue" onchange=changeValue('<%i%>')>
it works fine if i give alert(i) in
changeValue function.
Otherwise it gives error i is undefined.
Plz help me. I don't want to bother user by increasing one user click.
Plz help what is the reason ????
i m using struts 1.2
•
•
Join Date: Apr 2009
Posts: 17
Reputation:
Solved Threads: 0
This is my input text field
And this is my javaScript function is..
after giving that alert messsage it works otherwise not.
}
JSP Syntax (Toggle Plain Text)
<input type="text" id="productQuantity" size="5" onchange="changeQuantity(this.form,'<bean:write property="productCode" name="product"/>','<%=z %>');"/>
And this is my javaScript function is..
JavaScript Syntax (Toggle Plain Text)
function changeQuantity(form,productCode,index) { //alert("z==="+productCode); lengthOfItems=form.productCombo.options.length; lengthOfProducts=form.productCombo2.options.length; alert("index"+index); changeItemValueNew(form,productCode,index); }
after giving that alert messsage it works otherwise not.
}
Last edited by peter_budo; May 27th, 2009 at 11:01 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
First of all describe better what do you mean by this:
after giving that alert messsage it works otherwise not.
Also, firstly does the method being called correctly?
Try this to check the above:
Then see if the arguments are passed correctly:
Then try your code with alert messages between the other commands (like debugging) to see what is wrong
after giving that alert messsage it works otherwise not.
Also, firstly does the method being called correctly?
Try this to check the above:
JSP Syntax (Toggle Plain Text)
function changeQuantity(form,productCode,index) { alert("Method called"); }
Then see if the arguments are passed correctly:
JSP Syntax (Toggle Plain Text)
function changeQuantity(form,productCode,index) { alert(productCode); alert(index); }
Then try your code with alert messages between the other commands (like debugging) to see what is wrong
Check out my New Bike at my Public Profile at the "About Me" tab
•
•
Join Date: Feb 2009
Posts: 21
Reputation:
Solved Threads: 1
Create the variable in the javaScript
and store the value in it
then use it
and store the value in it
then use it
JSP Syntax (Toggle Plain Text)
function changeQuantity(form,productCode,index) { var z=productCode; var y=index; lengthOfItems=form.productCombo.options.length; lengthOfProducts=form.productCombo2.options.length; alert("index"+index); changeItemValueNew(form,z,y); }
•
•
•
•
Create the variable in the javaScript
and store the value in it
then use it
JSP Syntax (Toggle Plain Text)
var z=productCode; var y=index;
JSP Syntax (Toggle Plain Text)
var z=productCode; changeItemValueNew(form,z,y)
JSP Syntax (Toggle Plain Text)
changeItemValueNew(form,productCode,index);
Check out my New Bike at my Public Profile at the "About Me" tab
•
•
Join Date: Feb 2009
Posts: 21
Reputation:
Solved Threads: 1
Create the variable in the javaScript
and store the value in it
then use it
if you do calulation in java script, then you must be attentative
about the data type of the variable
java script is not strictly check the datatype of the variable
i do n't know what have you done in
method
and store the value in it
then use it
JSP Syntax (Toggle Plain Text)
function changeQuantity(form,productCode,index) { var z=productCode; var y=index; lengthOfItems=form.productCombo.options.length; lengthOfProducts=form.productCombo2.options.length; alert("index"+y); changeItemValueNew(form,z,y); }
if you do calulation in java script, then you must be attentative
about the data type of the variable
java script is not strictly check the datatype of the variable
i do n't know what have you done in
JSP Syntax (Toggle Plain Text)
changeItemValueNew(form,z,y)
method
•
•
•
•
i do n't know what have you done in
JSP Syntax (Toggle Plain Text)
changeItemValueNew(form,z,y)
method
Check out my New Bike at my Public Profile at the "About Me" tab
![]() |
Similar Threads
- HTML, CSS, JavaScript Developer (Web Development Job Offers)
- JavaScript / AJAX Guru (Software Development Job Offers)
- JSP sessions in javascript (JSP)
- Are you a PHP and Javascript junkie? It's time you met Emma. (Software Development Job Offers)
- Regarding doubt (JSP)
- JavaScript's window.opener (JavaScript / DHTML / AJAX)
- Javascript/HTML problem!!! (JavaScript / DHTML / AJAX)
- Javascript Useful? (IT Professionals' Lounge)
Other Threads in the JSP Forum
- Previous Thread: Jsp output in pdf file
- Next Thread: sleep a jsp page for a certain time
| Thread Tools | Search this Thread |
apache backbutton combobox connection database development directorystructure dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 network parameters passing ping printinserverinsteadofclient redirect request.getparameter response servlet servletdopost()readxml sessions software ssl state_saving_method stocks sun tomcat tutorial update video web






