Trouble with JAVASCRIPT function in HTML content

This is an open forum for any mojoPortal topics that don't fall into the other categories.

This thread is closed to new posts. You must sign in to post in the forums.
5/15/2012 9:10:03 AM
Gravatar
Total Posts 7

Trouble with JAVASCRIPT function in HTML content

Hi, been trying for a while, few days i guess, to call a function inside a HTML content panel, with no success. The code is below; i know it works, 'cause i had it on another asp site i had, but when i paste the code inside mojoportal HTML content it does not work. Would apreciate some help. Greets and tks from Lisbon.

 

<table border="0" cellpadding="10" cellspacing="0" width="424"> <tbody> <tr> <td background="/Data/Sites/1/GalleryImages/titleconsultaonline.gif" height="25"> &nbsp;</td> </tr> <tr> <td> <table align="center" border="0" cellpadding="0" cellspacing="10" width="100%"> <tbody> <tr> <td> <form action="enviarconsultaonline.php" method="post" name="frm" onsubmit="return valida(this)"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td width="1"> <img height="100" hspace="2" src="imagens/drlhuchoy.jpg" width="150" /></td> <td valign="top"> <div align="justify"> &nbsp;&nbsp;Disponibilizamo-nos para um aconselhamento profissional e eficaz sobre qualquer problema.<br /> <br /> &nbsp;&nbsp;Descreva neste formulário os seus sintomas para um adequado diagnóstico do seu problema.</div> </td> </tr> </tbody> </table> <img height="20" src="imagens/barra2.gif" width="380" /><br /> <table align="center" bgcolor="#e8f1ef" border="1" bordercolor="#808e8c" cellpadding="5" cellspacing="0" height="1" width="100%"> <tbody> <tr bordercolor="#e8f1ef"> <td align="right" width="20%"> <font color="#000000">Nome:</font></td> <td align="left" colspan="5"> <input id="nome" name="nome" style="width: 100%;" type="text" /></td> </tr> <tr bordercolor="#e8f1ef"> <td align="right"> <font color="#000000">Morada:</font></td> <td align="left" colspan="5"> <input id="morada" name="morada" style="width: 100%;" type="text" /></td> </tr> <tr bordercolor="#e8f1ef"> <td align="right"> <font color="#000000">Cód. Postal:</font></td> <td align="left" colspan="5"> <input id="codpostal1" maxlength="4" name="codpostal1" style="width: 20%;" type="text" /> - <input id="codpostal2" maxlength="3" name="codpostal2" style="width: 15%;" type="text" /> - <input id="localidade" name="localidade" style="width: 55%;" type="text" /></td> </tr> <tr bordercolor="#e8f1ef"> <td align="right"> <font color="#000000">Telefone:</font></td> <td align="left" colspan="5"> <input id="telefone" name="telefone" style="width: 50%;" type="text" /></td> </tr> <tr bordercolor="#e8f1ef"> <td align="right"> <font color="#000000">Email:</font></td> <td align="left" colspan="5"> <input id="email" name="email" style="width: 100%;" type="text" /></td> </tr> <tr bordercolor="#e8f1ef"> <td align="right"> <font color="#000000">Altura:</font></td> <td align="left" nowrap="nowrap"> <input id="altura" name="altura" style="width: 40px;" type="text" /> m</td> <td align="right"> <font color="#000000">Peso:</font></td> <td align="left" bordercolor="#e8f1ef" nowrap="nowrap"> <input id="peso" name="peso" style="width: 40px;" type="text" /> kg</td> <td align="right"> <font color="#000000">Idade:</font></td> <td align="left" nowrap="nowrap"> <input id="idade" name="idade" style="width: 40px;" type="text" /> anos</td> </tr> <tr bordercolor="#e8f1ef"> <td align="right" valign="top"> <font color="#000000">Sintomas:</font></td> <td align="left" colspan="5"> <textarea id="textarea" name="sintomas" rows="5" style="width: 100%;"></textarea></td> </tr> <tr bordercolor="#e8f1ef"> <td align="right" valign="top"> <font color="#000000">Obs:</font></td> <td align="left" colspan="5"> <textarea id="textarea2" name="obs" rows="5" style="width: 100%;"></textarea></td> </tr> <tr bordercolor="#e8f1ef"> <td align="right" valign="top"> &nbsp;</td> <td align="right" colspan="5"> <input id="enviar" name="enviar" type="submit" value="Enviar !" /></td> </tr> </tbody> </table> </form> </td> </tr> </tbody> </table> </td> </tr> <tr> <td background="imagens/barra.gif" height="30"> &nbsp;</td> </tr> </tbody> </table> <script> function valida(frm) { if (frm.nome.value.length == 0) { alert("Indique o seu nome!"); frm.nome.focus(); return false; } if (frm.morada.value.length == 0) { alert("Indique a sua morada!"); frm.morada.focus(); return false; } if (frm.localidade.value.length == 0) { alert("Indique a sua localidade!"); frm.localidade.focus(); return false; } if (frm.codpostal1.value.length == 0) { alert("Indique o seu código postal!"); frm.codpostal1.focus(); return false; } if (frm.localidade.value.length == 0) { alert("Indique a sua localidade!"); frm.localidade.focus(); return false; } if (frm.telefone.value.length == 0) { alert("Indique o seu telefone!"); frm.telefone.focus(); return false; } if (frm.altura.value.length == 0) { alert("Indique a sua altura!"); frm.altura.focus(); return false; } if (frm.peso.value.length == 0) { alert("Indique o seu peso!"); frm.peso.focus(); return false; } if (frm.sintomas.value.length == 0) { alert("Indique os seus sintomas!"); frm.sintomas.focus(); return false; } } </script>

5/15/2012 9:20:33 AM
Gravatar
Total Posts 18439

Re: Trouble with JAVASCRIPT function in HTML content

Hi,

"<form action="enviarconsultaonline.php" method="post" name="frm" onsubmit="return valida(this)">"

In ASP.NET WebForms there can be one and only one form element on a page and one already exists so you cannot add another one. 

If you need to do a custom form post you cannot do that using the html content feature, you would need to create a custom feature and use an <asp:Button

You can set the PostBackUrl on the button and this will make the alrerady existing form on the page post to the specified url.

See the articles:

Hope that helps,

Joe

5/16/2012 5:01:05 PM
Gravatar
Total Posts 7

Re: Trouble with JAVASCRIPT function in HTML content

Thks for the reply

Ok, understood and figure it out on how to do it, but question is, i saw only .asx files and those i have working are .asp ! can i somehow use/recycle them or should i convert or...

Thanks for the help, there is allways something about software that is totally new :)

Turbo

5/20/2012 5:11:42 PM
Gravatar
Total Posts 7

Re: Trouble with JAVASCRIPT function in HTML content

Hello, still wait for an answer! is it enough to just bind the code you have in one of your previous examples and safe the code as asx?

Thank u

JT

You must sign in to post in the forums. This thread is closed to new posts.