Getting value from function

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.



Go Back   Webforumz.com > Main Forums > Program Your Website > JavaScript Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old May 26th, 2006, 04:15
New Member
Join Date: May 2006
Location: earth
Age: 24
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation Getting value from function

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>
Reply With Quote

  #2 (permalink)  
Old May 26th, 2006, 13:06
Most Reputable Member
Join Date: Apr 2006
Location: Cornwall, UK
Posts: 1,310
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Skype™ to ukgeoff
Re: Getting value from function

Code: Select all
function myFunction(...){
   ...
   ...
   ...
   return someValue;
}
The variable someValue needs to hold whatever you wish to return from the called function.

BTW. In your second example above, you define two variable outside the <script>...</script> tags. This is not allowed.
Reply With Quote
  #3 (permalink)  
Old May 27th, 2006, 00:57
New Member
Join Date: May 2006
Location: earth
Age: 24
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
Reply

Tags
getting, value, function

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT. The time now is 10:44.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43