Link to home
Start Free TrialLog in
Avatar of Andrew Davis
Andrew DavisFlag for Australia

asked on

javascript calling second function.

Please let me start by saying that I am in no way a web coderm and am more at home with vbs and batch files, so please bear with me ;)

I have an ASP page that has a couple of dropdowns that trigger a page load.

The first drop down goes and populates a recordset with the with a list of domain names, and as soon as selecting a domain name reloads the current page and makes the answer available via Request.form

The second i want to do pretty much the same thing (allbeit that we are using email addresses as data), except i want to post the form to a different page.

I could do it simply by adding a "Submit" button, but i like the auto action on dropdown selection.

Here is a section of my code.
**The Domain on change works fine.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Page Title</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">

    function stopRKey(evt) {
        var evt = (evt) ? evt : ((event) ? event : null);
        var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
        if ((evt.keyCode == 13) && (node.type == "text")) { return false; }
    }

    document.onkeypress = stopRKey; 

</script> 

<script language="javascript">
<!--
    function domain_onchange(frmDomain) {
        frmDomain.submit();
    }
//-->
</script>
<script language="javascript">
<!--
    function email_onchange(frmAlias) {
        frmAlias.submit();
    }
//-->
</script>
</head>
<body>

Open in new window


and here is a section where i call the functions.
                'display the option to choose domain
                'select domains in managed list That dont use the default
                SQL = "Select * FROM tbl_localdomains where usedefaults = 0"
                SQL = SQL & " and id IN (" & replace(rs_tbl_UserSettings("Domain_IDs")," ","") & ")"
                set rs1 = con.execute(SQL)
                if rs1.eof then TestFail = 1
                if TestFail = 0 then
                    'Create dropdown choice box
                    %>
                    <form name="frmDomain" method="Post" action="settings.asp?Setting=NoLoginUser">
                    <SELECT name=domain LANGUAGE=javascript onchange="return domain_onchange(frmDomain)">
                        <option value="">Select Domain</option>
                        <%
                        while NOT rs1.eof %>
                            <option value="<%=rs1("domainname") %>" <%if Dom = rs1("domainname") then response.write "Selected"  %>><%=rs1("domainname") %></option>
                            <%rs1.movenext 
                        Wend %>
                    </select>
                    </form>
                    <%
                Else
                    Response.write "<h4>No Unregistered users for your domains</h4>"
                End If
'Test code-----------------------------------------
                            SQL = "Select * from tbllogins where email like '%" & Dom & "'"
'                            response.Write "SQL=" & SQL & "<br>"
                            set rstbllogins = con.execute(SQL)
                            %>
                            <form name="frmAlias" method="Post" action="settings.asp?Setting=Alias">
                            <SELECT name=email LANGUAGE=javascript onchange="return email_onchange(frmAlias)">
                                <option value="">Select Email</option>
                                <%
                                while NOT rstbllogins.eof %>
                                    <option value="<%=rstbllogins("EMail") %>" ><%=rstbllogins("Email") %></option>
                                    <%rstbllogins.movenext 
                                Wend %>
                            </select>
                            </form>
                            <%

'------------------------------------------------------

Open in new window


with this code currently if i use the dropdown to select the domain, it reloads the "Settings.asp" page with the selected post.
However the email drop down gets populated but when i select anything, nothing happens (like the script isnt triggered).

I am sure it is in the way of i have formatted it, and i have tried a few variations on the layout of the top code, but none have worked.

Any assistance much appreciated.

Cheers
Andrew
Avatar of Big Monty
Big Monty
Flag of United States of America image

the quick and easy way would be to change the ACTION attribute directly in your email function:

    function email_onchange(frmAlias) {
       frmAlias.action = 'settings.asp?Setting=Alias';
        frmAlias.submit();
    }
Avatar of Andrew Davis

ASKER

Thanks for your assistance.
I just tried that (Attached pic shows the code) and nothing happens. It is as though the script never triggers.

can i adjust the script so it just puts a popup, so we know it is even getting called?

Thanks for your help.
1.JPG
do you have a link to the site that I can have a look at? if not, please post the rendered code after you do a selection from the first dropdown
Unfortunately i cant get you access to the page itself.
But to simplify things i created a new page with all the SQL and other code gone (See below).

And it works.
<%@ LANGUAGE="VBScript" LCID=3081%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaTest</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />

<script language="javascript">
<!--
    function domain_onchange(frmDomain) {
        frmDomain.submit();
    }
//-->
</script>
<script language="javascript">
<!--
    function email_onchange(frmAlias) {
        frmAlias.submit();
    }
//-->
</script>
</head>
<body>
<%
    Response.Write "<h4>Header</h4>"

    'Actions
    response.write "Domain = " & request.Form("domain") & "<br>"
    response.write "Email = " & request.Form("email") & "<br>"

    'display the option to choose domain
    %>
    <form name="frmDomain" method="Post" action="javatest.asp?Setting=NoLoginUser">
    <SELECT name=domain LANGUAGE=javascript onchange="return domain_onchange(frmDomain)">
        <option value="">Select Domain</option>
            <option value="Domain1">Domain1</option>
            <option value="Domain2">Domain2</option>
            <option value="Domain3">Domain3</option>
    </select>
    </form>
    <%

'Email code-----------------------------------------
    %>
    <form name="frmAlias" method="Post" action="javatest.asp?Setting=Alias">
    <SELECT name=email LANGUAGE=javascript onchange="return email_onchange(frmAlias)">
        <option value="">Select Email</option>
            <option value="Email1" >Email 1</option>
            <option value="Email2" >Email 2</option>
            <option value="Email3" >Email 3</option>
    </select>
    </form>
    <%

'------------------------------------------------------
%>
</body>
</html>

Open in new window


So something in the rest of my code must be killing it.
I will try with renaming the form, as maybe it is used elsewhere.

the code on this page is 3328 Lines long (and very messy). but i can cut large sections (about a dozen sections) at a time to narrow down.

Are their any reasons that you know of why the script wouldn't trigger?
Would it help if i moved the script from the head to directly in front of the code that's calling it? (I don't think so as i seem to recall that script gets loaded in a particular order).

Cheers
Andrew
the location of the script is fine in the <head> tags, that's not the issue. try changing

return email_onchange(frmAlias)

to

return email_onchange(document.frmAlias)
also, ensure that there is no other form named frmAlias anywhere else on the form
return email_onchange(document.frmAlias)
No change.

ensure that there is no other form named frmAlias anywhere else on the form
Checked and there isn't, unless it is in an included file.
I am currently cutting (a Copy) the page apart to find what is triggering.

Thanks for your input.
ok maybe I misunderstood what you were asking. are you trying to get BOTH values to appear after you select from the second dropdown (email)? if that's the case, then I see where the problem is.

please confirm this is the case and I'll post the solution for you
i got it to start working on my cut down page.
What i had done was.
Originally i wanted the drop down in a table.
When that failed to simplify it i created a copy of the dropdown code outside the table, thinking that perhaps the table was upsetting it.
But at this point i now had two forms (one in the table, and one out) both named the same.

So on my cut down version of the page i deleted the table that was inside a table, and now the one outside the table works fine.

so i thought OK i will try putting it in a table on my JAVAtest.asp page (see below).
In this it works fine, and strangly the forms have different names ("frmAlias" and "frmAlias2") yet they both trigger the single function ?????

Thanks for persevering with me.

Cheers
Andrew
are you trying to get BOTH values to appear after you select from the second dropdown (email)?
No. They are different functions. When the domain is selected it gets saved to a session variable.

Sorry if i confused you ;)
can you post your updated code?

we'll get this bugger to work :)
I know what it is.... Yayyyyyyy

Not sure how to fix it. Boooooo.

Ok the problem is that i am populating the dropdown in a table that has a while/wend loop.

I have recreated the issue in this stand alone javatest.asp page.

and as i typed it out i could see that the issue was that the form was getting created multiple times, but not sure how to do it without that.

Ideas?

<%@ LANGUAGE="VBScript" LCID=3081%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaTest</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />

<script language="javascript">
<!--
    function domain_onchange(frmDomain) {
        frmDomain.submit();
    }
    function email_onchange(frmAlias) {
        frmAlias.submit();
    }
//-->
</script>
</head>
<body>
<%
    Response.Write "<h4>Header</h4>"

    'Actions
    response.write "Domain = " & request.Form("domain") & "<br>"
    response.write "Email = " & request.Form("email") & "<br>"

    'display the option to choose domain
    %>
    <form name="frmDomain" method="Post" action="javatest.asp?Setting=NoLoginUser">
    <SELECT name=domain LANGUAGE=javascript onchange="return domain_onchange(frmDomain)">
        <option value="">Select Domain</option>
            <option value="Domain1">Domain1</option>
            <option value="Domain2">Domain2</option>
            <option value="Domain3">Domain3</option>
    </select>
    </form>
    <%
    varCounter = 1
'Email code-----------------------------------------
    %>
<p>
<Table bgcolor="White" style=" color: #000000;" border="1" width="100%"> 
<tr>
    <th align="left" width="10%">EMail</th>
    <th align="left" width="10%">Alias</th>
    <th align="left" width="10%">Register Message Sent</th>
    <th align="left" width="10%">4</th>
</tr>
<%while varCounter < 5 %>
    <tr>
        <td><%=request.Form("email") %></td>
        <td>
            <form name="frmAlias2" method="Post" action="javatest.asp?Setting=Alias">
            <SELECT name=email LANGUAGE=javascript onchange="return email_onchange(frmAlias2)">
                <option value="">Select Email</option>
                    <option value="Email<%=varCounter%>" >Email<%=varCounter %></option>
            </select>
            </form>
        </td>
        <td>Date</td>
        <td>Text here</td>
    </tr>
    <%
    varCounter = varCounter + 1
wend
 %>
</Table></p>    
    <form name="frmAlias" method="Post" action="javatest.asp?Setting=Alias">
    <SELECT name=email LANGUAGE=javascript onchange="return email_onchange(frmAlias)">
        <option value="">Select Email</option>
            <option value="Email1" >Email 1</option>
            <option value="Email2" >Email 2</option>
            <option value="Email3" >Email 3</option>
    </select>
    </form>
</body>
</html>

Open in new window

the more i think, the uglier my code gets.
Perhaps i am thinking about it all wrong. So i will try to explain what i am wanting to achieve and perhaps you can guide me.

Objective.
Assign alias email address' to existing email accounts.
currently i can list the email accounts in a table.
i can also populate another recordset with available alias options.

Present the table with a column where i can dropdown an list to assign to the address that is listed in Column 1.

So what i just realized is i not only need the email that is selected in the dropdown, but i also need to know from what row it was selected......

I think my head has gone down the wrong path to start with and now i cant see the correct way.

ideas?

Cheers
i think i get what you're trying to do...how many rows are in the email table? is it a fixed amount or a dynamic amount?

are you looking to build a table with each row defined like this?

emailAddress              emailAlias          

do the aliases depend on what email. is selected?
heading to lunch, i'll tackle this in a bit
the list is dynamic.
Basically it pulls a list of addresses that dont have an alias, and gives them a option to declare one from another dynamic list of alias'

i thought i mite get away with something like.
<p>
<Table bgcolor="White" style=" color: #000000;" border="1" width="100%"> 
<tr>
    <th align="left" width="10%">EMail</th>
    <th align="left" width="10%">Alias</th>
    <th align="left" width="10%">Register Message Sent</th>
    <th align="left" width="10%">4</th>
</tr>
<form name="frmAlias" method="Post" action="javatest.asp?Setting=Alias">
<SELECT name=email LANGUAGE=javascript onchange="return email_onchange(frmAlias2)">
    <option value="">Select Email</option>
<%
while varCounter < 5 
%>
    <tr>
        <td><%=request.Form("email") %> - <%=varCounter %></td>
        <td>
                <%For i = 1 to 6 %>
                     <option value="Line<%=varCounter%>Email<%=i%>" >Email <%=i %></option>
                <%Next%>
        </td>
        <td>Date</td>
        <td>Text here</td>
    </tr>
    <%
    varCounter = varCounter + 1
wend
 %>
</select>
</form>
</Table>
</p>

Open in new window


where the counters are simply stepping through recordsets, but when i try this it renders only one dropdown box, and places it outside the table.

Cheers
Do the 2 drop downs need to be linked?  In other words, if you choose domain 2 in the first drop down, then do you only want to see results in the 2nd drop down that are specific to domain2?  If that is the case, it is a chained select and I have had great success using this jquery project http://www.appelsiini.net/projects/chained

You will see from their sample they use a car brand in the first set of value's.  This can be  your domain.  Then the 2nd the value is the detail and the class is the brand. The jquery they supply match's the value of the first to the class in the 2nd.  

What you would do is create 2 recordsets.  One with just the domains and the 2nd derived from a joined sql view that contains all the possibilities.  
<select id="mark" name="mark">
  <option value="">--</option>
  <option value="bmw">BMW</option>
  <option value="audi">Audi</option>
</select>
<select id="series" name="series">
  <option value="">--</option>
  <option value="series-3" class="bmw">3 series</option>
  <option value="series-5" class="bmw">5 series</option>
  <option value="series-6" class="bmw">6 series</option>
  <option value="a3" class="audi">A3</option>
  <option value="a4" class="audi">A4</option>
  <option value="a5" class="audi">A5</option>
</select>

Open in new window

Or am I not understanding your goal?
Just realized the time here is 2:53 am......
I am going to go to bed shortly and will re-visit this in the morning,

Please do not be offended if i dont post another update for several hours, but i will check all your suggestions, in the morning (or later morning), when perhaps my head is a little fresher.

Cheers
no the two options are not related.
Doing the dropdowns is relatively simple, but getting them linked into a form that submits on selection is what is giving me the problem.

Have a look at the code below which is a test page i made.

<%@ LANGUAGE="VBScript" LCID=3081%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaTest</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />

<script language="javascript">
<!--
    function domain_onchange(frmDomain) {
        frmDomain.submit();
    }
    function email_onchange(frmAlias) {
        frmAlias.submit();
    }
//-->
</script>
</head>
<body>
<%
    Response.Write "<h4>Header</h4>"

    'Actions
    response.write "Domain = " & request.Form("domain") & "<br>"
    response.write "Email = " & request.Form("email") & "<br>"

    'display the option to choose domain
    %>
    <form name="frmDomain" method="Post" action="javatest.asp?Setting=NoLoginUser">
    <SELECT name=domain LANGUAGE=javascript onchange="return domain_onchange(frmDomain)">
        <option value="">Select Domain</option>
            <option value="Domain1">Domain1</option>
            <option value="Domain2">Domain2</option>
            <option value="Domain3">Domain3</option>
    </select>
    </form>
    <%
    varCounter = 1
'Email code-----------------------------------------
    %>
<p>
<Table bgcolor="White" style=" color: #000000;" border="1" width="100%"> 
<tr>
    <th align="left" width="10%">EMail</th>
    <th align="left" width="10%">Alias</th>
    <th align="left" width="10%">Register Message Sent</th>
    <th align="left" width="10%">4</th>
</tr>
<form name="frmAlias" method="Post" action="javatest.asp?Setting=Alias">
<SELECT name=email LANGUAGE=javascript onchange="return email_onchange(frmAlias2)">
    <option value="">Select Email</option>
<%
while varCounter < 5 
%>
    <tr>
        <td><%=request.Form("email") %> - <%=varCounter %></td>
        <td>
                <%For i = 1 to 6 %>
                     <option value="Line<%=varCounter%>Email<%=i%>" >Email <%=i %></option>
                <%Next%>
        </td>
        <td>Date</td>
        <td>Text here</td>
    </tr>
    <%
    varCounter = varCounter + 1
wend
 %>
</select>
</form>
</Table>
</p>
</body>
</html>

Open in new window


The threads above are pretty clear (But Long) on what we are trying to acheive.

Thanks for any input, but i am going to have to go to sleep now.
Will review in 7-8 hours time.

Cheers
Andrew
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks heaps Monty.
I knew we would figure this out, and i really wanted to persuvere as i was learning something.

As i write this i have found with a butcher of your code, another way of doing it.
But i think your way will be a lot cleaner, so i am going to spend a bit longer on it to try to get my head around that.

After this post i will add some more with my alternate way, and what i end up settling on.
For no other purpose than to allow anyone that reads this to see the options, and feel free to ridicule my clumsy five thumb coding ;)

If you ever come to Brisbane, Australia, I will buy you a beer.

Cheers
Andrew
Okay so here is butcher 1 of Monty's solution.
as i hadnt worked with parseing more than one variable to Javascript function, at first i thought perhaps if i just populated my option boxes, then my issue would be to tell from which row(recordset) the selection had come from.

Low and behold when i tried this, the output that i got was a comma seperated value.
So with a simple instr() i was able to calculate the (Displayed) row, which would then allow me to step to the correct record to update.

While i am sure this would work, it is frought whith danger as if i ever change the order i would have to make sure that my action SQL copied the display exactly..

anyway here is the in-progress code. (I am using this in a standard .asp page and simulating the SQL side of things).

<%@ LANGUAGE="VBScript" LCID=3081%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaTest</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />

<script language="javascript">
<!--
    function domain_onchange(frmDomain) {
        frmDomain.submit();
    }
    function email_onchange(frmAlias) {
        frmAlias.submit();
    }
//-->
</script>
</head>
<body>
<%
    Response.Write "<h4>Header</h4>"

    'Actions
    response.write "Domain = " & request.Form("domain") & "<br>"
    response.write "Email = " & request.Form("email") & "<br>"
    if request.Form("email") <> "" then
        response.Write "Processing array<br>"
        'Split the string and find the line number that was clicked
        vLinenum = split(request.Form("email"),",")
        vcounter = 0
        for each y in vLinenum
'            response.write "Length=" & instr(y,"@") & "<br>"
            if instr(y,"@") > 1 then response.Write "Row " & vcounter & " = " & y & "<br>"
            vcounter = vcounter + 1
        Next
    End If

    'display the option to choose domain
    %>
    <form name="frmDomain" method="Post" action="javatest.asp?Setting=NoLoginUser">
    <SELECT name=domain LANGUAGE=javascript onchange="return domain_onchange(frmDomain)">
        <option value="">Select Domain</option>
            <option value="Domain1">Domain1</option>
            <option value="Domain2">Domain2</option>
            <option value="Domain3">Domain3</option>
    </select>
    </form>
    <%
    varCounter = 1
'Email code-----------------------------------------
    %>
<p>
<form name="frmAlias" method="Post" action="javatest.asp?Setting=Alias">
<Table bgcolor="White" style=" color: #000000;" border="1" width="100%"> 
<tr>
    <th align="left" width="10%">EMail</th>
    <th align="left" width="10%">Alias</th>
    <th align="left" width="10%">Register Message Sent</th>
    <th align="left" width="10%">Row Number / Record Number</th>
</tr>
<%
SelectEmailAlias = "<SELECT name=""email"" LANGUAGE=javascript onchange=""return email_onchange(frmAlias)"">"
SelectEmailAlias = SelectEmailAlias & "<option value="""">Select Email</option>"
aliasCounter = 0    'Using aliasCounter to simulate stepping through a record set of possible alias'
do while aliasCounter < 50 
    SelectEmailAlias = SelectEmailAlias & "<option value=""Ema@il" & aliasCounter &""" >Ema@il " & aliasCounter & "</option>"
    aliasCounter = aliasCounter + 1
Loop
SelectEmailAlias = SelectEmailAlias & "</select>"

varCounter = 0  'Using varCounter to simulate stepping through a recordset of Email address'
do while varCounter < 150 
    vEmail = "row" & varCounter & "@testdomain.com" 'generating unique email address' this would normally come from the recordset.
%>
    <tr>
        <td><%=vEmail %></td>
        <td><%=SelectEmailAlias%></td>
        <td>Date</td>
        <td><%=varCounter %></td>
    </tr>
    <%
    varCounter = varCounter + 1
loop
 %>
</select>
</form>
</Table>
</p>
</body>
</html>

Open in new window

OK Got it working.

I have used Monty's script.
Note there are two Errors in his script that will Kill it:-

1. where there is "onclick" you have to change this to "onchange", otherwise the script fires as soon as you drop down the box, prior to making a selection.

2. in line 103 of his code you need to change to  "selectEmailAliasNew = Replace( selectEmailAlias, whatToReplace, whatToReplaceWith )" and Line 107 change to "<td><%=selectEmailAliasNew%></td>" The reason is that if you change (Replace) the original string, after the first change it will never do the replace again as the string it is looking for no longer exists.

So here is my working code. As per before i have replaced SQL sections for simulated data.
<%@ LANGUAGE="VBScript" LCID=3081%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JavaTest</title>
<meta name="Keywords" content="" />
<meta name="Description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />

<script language="javascript">
<!--
    function domain_onchange(frmDomain) {
        frmDomain.submit();
    }
    function email_onchange(alias, email) {
        document.frmAlias.action = 'JavaTest.asp?Setting=Alias&email=' + email + '&alias=' + alias;
        document.frmAlias.submit();
    }
//-->
</script>
</head>
<body>
<%
    Response.Write "<h4>Header</h4>"

    'Actions
    response.write "Domain = " & request.Form("domain") & "<br>"
    email = Request.QueryString("email") 'ADA Copied from Above
    alias = Request.QueryString("alias") 'ADA Copied from Above
    response.write "Email = " & email & "<br>"
    response.write "Alias = " & alias & "<br>"

    'display the option to choose domain
    %>
    <form name="frmDomain" method="Post" action="javatest.asp?Setting=NoLoginUser">
    <SELECT name=domain LANGUAGE=javascript onchange="return domain_onchange(frmDomain)">
        <option value="">Select Domain</option>
            <option value="Domain1">Domain1</option>
            <option value="Domain2">Domain2</option>
            <option value="Domain3">Domain3</option>
    </select>
    </form>
    <%
    varCounter = 1
'Email code-----------------------------------------
    %>
<p>
<form name="frmAlias" method="Post" action="javatest.asp?Setting=Alias">
<Table bgcolor="White" style=" color: #000000;" border="1" width="100%"> 
<tr>
    <th align="left" width="10%">EMail</th>
    <th align="left" width="10%">Alias</th>
    <th align="left" width="10%">Register Message Sent</th>
    <th align="left" width="10%">Row Number / Record Number</th>
</tr>
<%
SelectEmailAlias = "<select name=""Email"" onchange=""return email_onchange( this.value );""><option value=''>Select Email Alias</option>"
aliasCounter = 0    'Using aliasCounter to simulate stepping through a record set of possible alias'
do while aliasCounter < 5
    tvAlias = "Alias" & AliasCounter & "@tester.com"
    selectEmailAlias = selectEmailAlias & "<option value='" & tvAlias & "' >" & tvAlias & "</option>" 'ADA removed the selected as i dont care.
    aliasCounter = aliasCounter + 1
Loop
SelectEmailAlias = SelectEmailAlias & "</select>"

varCounter = 0  'Using varCounter to simulate stepping through a recordset of Email address'
do while varCounter < 15 
    vEmail = "Email" & varCounter & "@tester.com" 'generating unique email address' this would normally come from the recordset.
    whatToReplaceWith = "onchange=""return email_onchange( this.value, '" & vEmail & "' );"""
    vWhatToReplace = "onchange=""return email_onchange( this.value );"""
    SelectEmailAliasNew = replace(SelectEmailAlias, vWhatToReplace, whatToReplaceWith) 'ADA you cant change the original selectEmailAlias, otherwise it will never work aftre the first change as the whatToReplace will never match.
%>
    <tr>
        <td><%=vEmail %></td>
        <td><%=SelectEmailAliasNew%></td>
        <td>Date</td>
        <td><%=varCounter %></td>
    </tr>
    <%
    varCounter = varCounter + 1
loop
 %>
</select>
</form>
</Table>
</p>
</body>
</html>

Open in new window

that's great, I'm glad you got it working the way you wanted to :)

Never been to Brisbane, but had a 4 hour lay over in Sydney on my way to New Zealand. I'll def take you up on the beer offer though if I ever make my way down there :)

Cheers
Josh