Click to See Complete Forum and Search --> : Create referance No


taurz
10-22-2003, 02:24 AM
HI!!

I am trying to create a referance no dynamically on the basis of the data inputed by the user.

I have a pull-down list and a text box. The user first selects from A,B,C,D in the list box. Then he goes to the text box and types in a number. Once he moves out of the text box, the referance number has to be created dynamically and be placed on the next line.

The referance number consists of

AIC/X/YYYY/MM/NNN

AIC is common - it is part of all referance numbers
X is the A,B,C or D from the list
YYYY is the current year
MM is the current month
NNN is the number inserted in the text box

How do I go about this? I am pretty new to java scripting. A few guidelines would be apprecated. Thanx for the help

TAURZ

Gollum
10-22-2003, 04:20 AM
Here's an example that should do something like what you want ...

<html>
<head>
<script>
function calculate()
{
var d = new Date;
var m = d.getMonth() + 1;
var y = d.getYear();
var x = document.f.x.value;
var n = document.f.n.value;
if ( n == "" ) n = "NNN";

document.getElementById('refNo').innerHTML = "AIC/" + x + "/" + y + "/" + m + "/" + n;
}
</script>
</head>
<body onload="calculate();">
<form name=f>
<select name=x onchange="calculate();">
<option value=A>A
<option value=B>B
<option value=C>C
<option value=D>D
</select><br>
Number:<input type=text name=n onblur="calculate();"><br>
<span id=refNo></span>
</form>
</body>
</html>

taurz
10-22-2003, 05:53 AM
thanx a lot Gollum

that worked perfect... although I have to do required changes, that gave me my skeleton structure to work with

taurz
10-23-2003, 12:17 AM
hi... just another Q...

What if i want to pass the referance no from the javascript to the next page? Actually my next page is an ASP page that inserts the data into a database. So, this has to be inserted into a database.

Thanx for ur help...