This is a discussion on "Getting value from function" within the JavaScript Forum section. This forum, and the thread "Getting value from function are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Getting value from function
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
for example this function get a value from a textbox and calculate and return the value to another textbox. this example can work.
------------------------------------- <script type="text/javascript"> function chkBreakdown(){ myForm=document.brk total=50*myForm.brkID.value myForm.brk_total.value=total; } </script> <html> <body> <form name="brk"> <input type="text" name="brkID" value="0" size="3" maxlength="3" onblur="chkBreakdown()"> <input type="text" name="brk_total"> </form> </body> </html> ------------------------------------------ now my problem is for example below: Vector wp = new Vector(); Vector ln = new Vector(); <script type="text/javascript"> function chkBreakdown(wp,ln,la){ myForm=document.brk total=wp+ln+la+*myForm.brkID<%=c%>.value <--is this correct or not? myForm.brk_total.value=total; } </script> <html> <body> <form name="brk"> <tr><td>LA no.</td><td>: <input type=text id="laNo" size=6 style="border:0" value='<%=la_no%>'> </td></tr> <%for(int c=0; c<wp.size(); c++){%> <td><input type="text" size=5 name="wp<%=c%>" value='<%=wp.elementAt(c)%>'></td> <td><input type="text" size=4 name="ln<%=c%>" value='<%=ln.elementAt(c)%>'></td> <td><input type="text" size=8 name="brkID<%=c%>" id="brkID" value='<%=brkID.elementAt(c)%>' onFocus="chkBreakdown('<%=wp.elementAt(c)%>','<%=l n.elementAt(c)%>','<%=la_no%>');"></td> </form> <input type="text" name="brk_total"> </body> </html> |
|
|
|
|||
|
Re: Getting value from function
BTW. In your second example above, you define two variable outside the <script>...</script> tags. This is not allowed. |
|
|||
|
Re: Getting value from function
oh in my second example, ya i know, i should write like this
<%! Vector wp = new Vector(); Vector ln = new Vector(); %> then how about this sentence of code, izzit correct? <td><input type="text" size=8 name="brkID<%=c%>" id="brkID" value='<%=brkID.elementAt(c)%>' onFocus="chkBreakdown('<%=wp.elementAt(c)%>','<%=l n.elementAt(c)%>','<%=la_no%>');"></td> when on focus, then call a function together with 3 parameters. |
![]() |
| Tags |
| getting, value, function |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| using the array_unique function | eon201 | PHP Forum | 1 | Nov 12th, 2007 13:54 |
| DateTime Function | tanya_1985_am | Classic ASP | 5 | Oct 12th, 2007 16:42 |
| Mail function | alexgeek | PHP Forum | 4 | Sep 22nd, 2007 12:18 |
| onclick function | tomd1985 | JavaScript Forum | 0 | Mar 13th, 2006 18:20 |
| SQL Function | spinal007 | Databases | 1 | Mar 25th, 2005 09:43 |