Auto Submit

S

scott

I have a combo in LISTING 2 that I'm trying to force a sumbit when a user
makes a change. Can anyone see why it doesn't fire LISTING 2 code?
It just doesn't do anything. What I'm really trying to do is access the
value of the combo after a user makes a change. I'm just hardcoding the
teamID querystring in this example.

LISTING 1
-------------
<script type=text/javascript>

function showTeams()
{
document.addForm.action = "./mypage.asp?teamID=5";
document.addForm.submit();
}
</script>



LISTING 2
------------
<form action="mypage.asp" method="post" name="addForm">

<select class="FormTextBox" name="cboCategory"
onchange="javascript:showTeams();">

<OPTION value="1">Work Schedule</OPTION>
<OPTION value="2">Meeting</OPTION>
<OPTION value="3">Mills</OPTION>
<OPTION value="5">Teams</OPTION>
</select>
 
R

Ray Costanzo [MVP]

Works fine for me in IE. I suggest, since this is a client-side issue and
not an ASP one, that you investigate further in a client-side group, such as
m.p.scripting.jscript.

Ray at home
 
S

scott

OK guys, I found the real problem because my simple submitted version worked
for me also.

IThe combo in LISTING 2 fires the Onchange event perfect. However, LISTING 3
will not fire my ONCHANGE event because I've inserted a "hidden" field after
the form tag. Now, if I have a hidden form element anywhere inside the form
tags, onchange won't fire.

Why would a 'hidden' form element cause a javascript onchange event to not
work?


LISTING 1 (WORKS)
-------------
<script type=text/javascript>

function showTeams()
{
document.addForm.action = "./mypage.asp?teamID=5";
document.addForm.submit();
}
</script>



LISTING 2 (WORKS)
------------
<form action="mypage.asp" method="post" name="addForm">

<select class="FormTextBox" name="cboCategory"
onchange="javascript:showTeams();">

<OPTION value="1">Work Schedule</OPTION>
<OPTION value="2">Meeting</OPTION>
<OPTION value="3">Mills</OPTION>
<OPTION value="5">Teams</OPTION>
</select>


LISTING 3 (DOESN'T WORK)
------------
<form action="mypage.asp" method="post" name="addForm">

<select class="FormTextBox" name="cboCategory"
onchange="javascript:showTeams();">

<OPTION value="1">Work Schedule</OPTION>
<OPTION value="2">Meeting</OPTION>
<OPTION value="3">Mills</OPTION>
<OPTION value="5">Teams</OPTION>
</select>
 
S

scott

what's the full name of the jscript group?

Ray Costanzo said:
Works fine for me in IE. I suggest, since this is a client-side issue and
not an ASP one, that you investigate further in a client-side group, such
as m.p.scripting.jscript.

Ray at home
 
B

Bob Lehmann

Now, if I have a hidden form element anywhere inside the form tags,
onchange won't fire.

Sure it will....

<form action="mypage.asp" method="post" name="addForm">

<select class="FormTextBox" name="cboCategory" onchange="showTeams();">

<OPTION value="1">Work Schedule</OPTION>
<OPTION value="2">Meeting</OPTION>
<OPTION value="3">Mills</OPTION>
<OPTION value="5">Teams</OPTION>
</select>
<input type="hidden">
</form>.

Listing 3 is identical to Listing 2. When you post to the client-side group
(microsoft.public.scripting.jscript), include *all* of what you say doesn't
work.

Bob Lehmann
 
S

scott

i will goto jscript group, but just to let you know, the "hidden" form
element will ONLOY work as you posted, try giving it a name and value and
the onchange event causes error.
 
B

Bob Lehmann

OK....
<form action="mypage.asp" method="post" name="addForm">

<select class="FormTextBox" name="cboCategory" onchange="showTeams();">

<OPTION value="1">Work Schedule</OPTION>
<OPTION value="2">Meeting</OPTION>
<OPTION value="3">Mills</OPTION>
<OPTION value="5">Teams</OPTION>
</select>
<input type="hidden" name="hdn" value="12">
</form>

Still works.

<ot>
So what error are you getting? Post a *complete* sample of your code.
</ot>

Bob Lehmann
 
S

scott

ERROR: nothing happens, the yellow js error icons says "Object doesn't
support this property or method"

Note: If I delete name and value on hidden element, works fine.


FULL CODE:

<html>
<head>
<title>Calendar Admin</title>

<link rel="stylesheet" type="text/css" href="library/IntranetStyle01.css">

<style type="text/css">
TD {
font-family:verdana,arial,sans-serif;
font-size:10pt;
color:#333366;
}
.FormTextBox {
border:solid 1pt #008080;
font-family:verdana,sans-serif;
font-size:10pt;
color:#000000;
background-color:#ffffee;
}

</style>

<script type=text/javascript>

function showTeams()
{
document.addForm.action = "combo_test1.asp?action=add&teamID=6";
document.addForm.submit();
}
</script>

<body>


<form action="combo_test1.asp" method="post" name="addForm">
<input type="hidden" name="action" value="add_process">

<select class="FormTextBox" name="cboCategory"
onchange="javascript:showTeams();">

<OPTION value="1">Work Schedule</OPTION>
<OPTION value="2">Meeting</OPTION>
<OPTION value="3">Mills</OPTION>
<OPTION value="5">Teams</OPTION>
</select>

</form>
</body>

</html>
 
S

scott

problem solved, i was using the reserved word "action" as a form element
name. thanks for all help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top