hi there,
i was new using java on web.
i want to get the first letter of the field using java script, how would be my code be? Just like using @left in formula language, or left in lotus script…
thankyou.
hi there,
i was new using java on web.
i want to get the first letter of the field using java script, how would be my code be? Just like using @left in formula language, or left in lotus script…
thankyou.
Subject: java on web application
hi there., one more thing, the codes keep prompting a message box with the value, what i need to do is store the value in another field, what will i need to do… i try the code in a blur() objects.
var f = document.forms[0];
mail = HR_FIRST_NAME.value.substring(0, 1)
f.HR_UFO_FullName.value = mail
it gets the value of the field but i must put it in another field not just prompt it…
thank you
Subject: Don’t need the temp variable
You don’t even need the intermediate variable assignment; you can do this:
var f = document.forms[0];
f.HR_UFO_FullName.value = HR_FIRST_NAME.value.substring(0, 1);
However, what you did should work. Check your target field name; remember Javascript is case-sensitive.
Subject: Javascript != Java
First, just to be clear - Javascript and Java are not the same thing. There are multiple ways to do what you want as Javascript String provide several handy functions to do what you want.
e.g:
var f = document.forms[0];
alert( myField.value.charAt(0))
alert( myField.value.substr(0,1))
alert( myField.value.slice(0,1))
alert( myField.value.substring(0,1))
Each function works differently however (except slice and substring which are the same). charAt returns a single character from a specified index, the others all return a substring (of any length).
More detail at: String - JavaScript | MDN
Subject: RE: Javascript != Java
Thankyou Gerry. it works…