Advertisement

Problem with form submit

Moderators: Calcifer, slothy

Problem with form submit

Postby eophotos » Wed Jan 24, 2007 8:55 am

Hello there!

I am running into a problem with using the DHTMLgoodies calendar. I have an image with an OnClick event for the calendar pop up, within a form with a Submit button.

Yet everytime I click on the calendar image my form gets submitted.


Here is my code:

<form action="<%=MM_editAction%>" method="POST" name="ins_Update" id="ins_Update">
<table width="640" border="0" cellpadding="0" cellspacing="0" class="txt">
<tr height="10">
<td width="10"></td>
<td></td>
</tr>
<tr height="1">
<td></td>
<td class="top_wall"><img src="../Images/Layout/transparent.gif"></td>
</tr>
<tr height="10">
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="form-hdr">Add an event</td>
</tr>
<tr height="20">
<td colspan="2"></td>
</tr>
<tr>
<td></td>
<td>
<dl>
<dt>
<dt><label id="Whenlabel" for="theDate" style="visibility:hidden;">When (DD/MM/YYYY)</label></dt>
<dd><INPUT name="theDate" type="text" class="TextField" id="theDate" tabindex="4" size="50" maxlength="50" style="visibility:hidden;" value="<%=Day(Date) & "/" & Month(Date) & "/" & Year(Date) %>"><img src="..\Layout\cal.gif" value="Cal" onclick="displayCalendar(document.forms[0].theDate,'dd/mm/yyyy',this);"></dd>
</dl>
</td>
</tr>
<tr height="20">
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input name="Submit" type="submit" class="Buttons" value="Add">
</td>
</tr>
</table>

</form>

I would really appreciate if you could tell me how to solve this problem.

Many thanks!
eophotos
 
Posts: 6
Joined: Wed Aug 23, 2006 2:41 pm

Postby Batalf » Wed Jan 24, 2007 10:55 am

Hi

Click on an image shouldn't submit the form unless you are using <input type="image">

I'm afraid the code you posted won't help me much. I need to see the code rendered in the browser, i.e. the one you'll get by selecting view->source from the context menu of the browser.
Batalf
Site Admin
 
Posts: 2160
Joined: Sat Oct 22, 2005 9:38 pm

Postby eophotos » Wed Jan 24, 2007 11:04 am

OK here is the whole page once rendered:


<html><!-- #BeginTemplate "/Templates/admin.dwt" --><!-- DW6 -->
<head>
<!-- #BeginEditable "doctitle" -->
<link rel="stylesheet" href="../Components/dhtmlgoodies_calendar.css?random=20051112" media="screen"></LINK>
<script type="text/javascript" src="../Components/dhtmlgoodies_calendar.js?random=20060118"></script>
<script language="JavaScript" type="text/javascript">
<!--

function ShowTB(obj){
txt=obj.options[obj.selectedIndex].text;
if (txt.match('News')){
document.getElementById('Event').style.visibility='hidden';
document.getElementById('Eventlabel').style.visibility='hidden';
document.getElementById('theDate').style.visibility='hidden';
document.getElementById('Whenlabel').style.visibility='hidden';
document.getElementById('Location').style.visibility='hidden';
document.getElementById('Locationlabel').style.visibility='hidden';
}
if (txt.match('Exhibition')){
document.getElementById('Event').style.visibility='visible';
document.getElementById('Eventlabel').style.visibility='visible';
document.getElementById('theDate').style.visibility='visible';
document.getElementById('Whenlabel').style.visibility='visible';
document.getElementById('Location').style.visibility='visible';
document.getElementById('Locationlabel').style.visibility='visible';
}
if (txt.match('Publication')){
document.getElementById('Event').style.visibility='hidden';
document.getElementById('Eventlabel').style.visibility='hidden';
document.getElementById('theDate').style.visibility='visible';
document.getElementById('Whenlabel').style.visibility='visible';
document.getElementById('Location').style.visibility='hidden';
document.getElementById('Locationlabel').style.visibility='hidden';
}
if (txt.match('Workshop')){
document.getElementById('Event').style.visibility='visible';
document.getElementById('Eventlabel').style.visibility='visible';
document.getElementById('theDate').style.visibility='visible';
document.getElementById('Whenlabel').style.visibility='visible';
document.getElementById('Location').style.visibility='visible';
document.getElementById('Locationlabel').style.visibility='visible';
}
}

//-->
</script>
<!-- #EndEditable -->
<title>xxx</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
<LINK href="../Styles/Style.css" rel="stylesheet" type="text/css">
</head>
<body link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" bgcolor="#575656">
<!-- DO NOT MOVE! The following AllWebMenus code must always be placed right AFTER the BODY tag-->
<!-- ******** BEGIN ALLWEBMENUS CODE FOR menuad ******** -->
<span id='xawmMenuPathImg-menuad' style='position:absolute;top:-50px'><img name='awmMenuPathImg-menuad' id='awmMenuPathImg-menuad' src='../awmmenupath.gif' alt=''></span><script type='text/javascript'>var MenuLinkedBy='AllWebMenus [4]', awmBN='624'; awmAltUrl='';</script><script charset='UTF-8' src='../menuad.js' language='JavaScript1.2' type='text/javascript'></script><script type='text/javascript'>awmBuildMenu();</script>
<!-- ******** END ALLWEBMENUS CODE FOR menuad ******** -->
<div id="master">
<div id="topshadow"><span></span></div>
<div id="main">
<div id="headeradmin"></div>
<div id="awmAnchor-menuad"></div>
<div id="Layer1"><!-- #BeginEditable "Main Work Area" -->
<form action="/xxxx/extended_events.asp" method="POST" name="ins_Update" id="ins_Update">
<table width="640" border="0" cellpadding="0" cellspacing="0" class="txt">
<tr height="10">
<td width="10"></td>
<td></td>
</tr>
<tr height="1">
<td></td>
<td class="top_wall"><img src="../Images/Layout/transparent.gif"></td>
</tr>
<tr height="10">
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td class="form-hdr">Add an event to the database</td>
</tr>
<tr height="20">
<td colspan="2"></td>
</tr>
<tr>
<td></td>
<td>
<dl>
<dt><label for="Category" accesskey="9">Category</label></dt>
<dd><select name="Category" class="TextField" id="Category" tabindex="1" onChange="ShowTB(this);">
<option value="News">News</option>
<option value="Exhibition">Exhibition</option>
<option value="Publication">Publication</option>
<option value="Workshop">Workshop, Seminar</option>
</select></dd>
<dt><label id="Eventlabel" for="Event" style="visibility:hidden;">Title</label></dt>
<dd><INPUT name="Event" type="text" class="TextField" id="Event" tabindex="2" size="70" style="visibility:hidden;"></dd>
<dt><label for="Description">Description</label></dt>
<dd><textarea name="Description" cols="70" rows="4" class="TextField" tabindex="3" id="Description"></textarea></dd>
<dt><label id="Whenlabel" for="theDate" style="visibility:hidden;">When (DD/MM/YYYY)</label></dt>
<dd><INPUT name="theDate" type="text" class="TextField" id="theDate" tabindex="4" size="50" maxlength="50" style="visibility:hidden;" value="24/1/2007"><img src="..\Layout\cal.gif" onclick="displayCalendar(document.forms[0].theDate,'dd/mm/yyyy',this);"></dd>
<dt><label id="Locationlabel" for="Location" style="visibility:hidden;">Where</label></dt>
<dd><INPUT name="Location" type="text" class="TextField" id="Location" tabindex="5" size="60" maxlength="256" style="visibility:hidden;"></dd>
</dl>
</td>
</tr>
<tr height="20">
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input name="Submit" type="submit" class="Buttons" value="Add">
</td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="ins_Update">
</form>
<!-- #EndEditable --></div>
<div id="Bottom"></div>
</div>
<div id="bottomshadow"><span></span></div>
</div>
</body>
<!-- #EndTemplate --></html>

Thanks for your help !
eophotos
 
Posts: 6
Joined: Wed Aug 23, 2006 2:41 pm

Postby Batalf » Wed Jan 24, 2007 3:50 pm

I can't find anything in your code which should cause the form to submit when you click on the calendar image.

It doesn't submit the form in any of my browsers(IE and FF) when I try your code locally here.

I'm not sure what to do in order to help you further. There are probably something else on your page causing it to act like this. There are no form submission codes in the calendar script.
Batalf
Site Admin
 
Posts: 2160
Joined: Sat Oct 22, 2005 9:38 pm


Return to Calendar script questions

Who is online

Users browsing this forum: No registered users and 12 guests

cron