JavaScript (aka js)

Javascript: Apprendre le Javascript depuis le PHP, et conditions, excellents articles qui mentionnent notamment Objets globaux (MDN)

intranet

history.go(-1) / history.back()

Libraries

jQuery

http://jquery.com/

jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages

angularJS

AngularJS est un framework JavaScript libre et open-source développé par Google. Google c'est mal, mais angularJs c'est intéressant.

http://www.journaldunet.com/developpeur/outils/tutoriel-angularjs.shtml

Editeurs JavaScript

éditer js est une vraie daube

les éditeurs suivants, je les ai testés mais ne suis pas vraiment convaincus… j'utilise principalement eclipse, après des années d'emacs et vi, si vous avez des suggestions je suis preneur!

xinha

http://xinha.webfactional.com/

Xinha (pronounced like Xena, the Warrior Princess) is a powerful WYSIWYG HTML editor component that works in all current browsers. Its configurabilty and extensibility make it easy to build just the right editor for multiple purposes, from a restricted mini-editor for one database field to a full-fledged website editor. Its liberal, BSD licence makes it an ideal candidate for integration into any kind of project.

Xinha is Open Source, and we take this seriously. There is no company that owns the source but a community of professionals who just want Xinha to be the best tool for their work.

fckeditor

http://www.fckeditor.net/

This HTML text editor brings to the web much of the power of desktop editors like MS Word. It's lightweight and doesn't require any kind of installation on the client computer.

tinymce

http://tinymce.moxiecode.com/

TinyMCE is a platform independent web based Javascript HTML WYSIWYG editor control released as Open Source under LGPL by Moxiecode Systems AB. It has the ability to convert HTML TEXTAREA fields or other HTML elements to editor instances. TinyMCE is very easy to integrate into other Content Management Systems.

Various Scripts

debug

antispam

petit script pour éviter les spammeurs cherchant les “mailto:” démo http://radeff.red/info/js/antispam.html

<html>
<body>
<title>ANTISPAM JS</title>
<h1>ANTISPAM JS</h1>
<script language="JavaScript"><!--
emailE=('john.doe@'+'nospamming.com')
document.write(
  '<A HREF="mailto:' + emailE + '">' 
  + emailE + '</a>'
)
//--></script>

Autocompletion

Pour assister la saisie dans un formulaire à l'aide d'une série de mots-clés exemple http://radeff.red/info/js/autocompletion.php

<html>
<head>
<title>input autocompletion</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var riders = [
  "Armstrong",
  "Indurain",
  "Lemond",
  "Pantani",
  "Riis",
  "Ullrich"
];
function autoComplete (dataArray, input, evt) {
  if (input.value.length == 0) {
    return;
  }
  var match = false;
  for (var i = 0; i < dataArray.length; i++) {
    if ((match = dataArray[i].toLowerCase().indexOf
(input.value.toLowerCase()) == 0)) {
      break;
    }
  }
  if (match) {
    var typedText = input.value;
    if (typeof input.selectionStart != 'undefined') {
      if (evt.keyCode == 16) {
        return;
      }
      input.value = dataArray[i];
      input.setSelectionRange(typedText.length, input.value.length);
    }
    else if (input.createTextRange) {
      if (evt.keyCode == 16) {
        return;
      }
      input.value = dataArray[i];
      var range = input.createTextRange();
      range.moveStart('character', typedText.length);
      range.moveEnd('character', input.value.length);
      range.select();
    }
    else {
      if (confirm("Are you looking for '" + dataArray[i] + "'?")) {
        input.value = dataArray[i];
      }
    }
  }
}
  
</script>
</head>
<body>
<form name="gui">
<label>
Enter Tour de France Winner:
<input type="text" name="tdfWinner"
       onkeyup="autoComplete(riders, this, event);"
       autocompletion="off">
  </label> source: http://www.faqts.com/knowledge_base/view.phtml/aid/1174/fid/178 
</form>

</body>
</html>

autre solution: passer par ajax, exemples sur http://script.aculo.us/

back to top

pour afficher en permanence une image pour remonter en haut du fichier (zip file) http://radeff.red/info/js/bak2top.zip

body on unload

body onUnload="alert('dsd');"
permet d'effectuer un truc lorsque l'utilisateur ferme une fenêtre dans un browser, style : ceux qui n'utilisent pas le button 'logout'.... 
(Laurent)

Calcul de la longueur d'un string

http://radeff.red/info/js/length.html

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="GENERATOR" content="Mozilla/4.6 [fr] (Win95; I) [Netscape]">
   <title>Calcul de la longueur d'une cha&icirc;ne de caract&egrave;res</title>
<script language="JavaScript">

function longueur() {

z=document.cherche.texte.value
y=z.length
alert("La longueur du texte: " +z +" est de " +y)
}

</script>
</head>
<body>
<form name="cherche">Entrez
le texte dont vous voulez conna&icirc;tre la longueur ici puis clickez
sur le bouton:
<br><textarea name="texte" ROWS=10 COLS=60></textarea><input type="submit" value="calcule longueur" onClick=longueur()></form>

</body>
</html>

Confirmer l'effacement / confirm delete

<script type="text/javascript">
function confirmer(id) {
  var r=confirm("Effacer l'enregistrement?");
  if (r==true)  {
  document.location.href="deleteDictionnary.php?id="+id;
  return true;
 }
  else {
  return false;
  }
  }
</script>
...
<img src=\"common/b_empty.png\" onclick='confirmer(" .$id.")' alt=\"effacer\" title=\"effacer\">

pour afficher s'il y a eu une modification depuis la dernière visite

<body>
<SCRIPT LANGUAGE="JavaScript">

<!--Javascript issu de Script Masters-->
<!-- http://www.script-masters.com/--> 

function getCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg)
			return getCookieVal (j);
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break; 
		}
	return null;
	}

function SetCookie (name, value) {
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : null;
	var path = (argc > 3) ? argv[3] : null;
	var domain = (argc > 4) ? argv[4] : null;
	var secure = (argc > 5) ? argv[5] : false;
	document.cookie = name + "=" + escape (value) +
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	((path == null) ? "" : ("; path=" + path)) +
	((domain == null) ? "" : ("; domain=" + domain)) +
	((secure == true) ? "; secure" : "");
	}

function DeleteCookie(name) {
	var exp = new Date();
	FixCookieDate (exp);
	exp.setTime (exp.getTime() - 1);
	var cval = GetCookie (name);
	if (cval != null)
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
	}

var cookie_date=new Date(document.lastModified);
var expdate = new Date();
expdate.setTime(expdate.getTime()+(5*24*60*60*1000));
document.write("");
if (!(cookie_date == GetCookie("cookie_date"))){
	SetCookie("cookie_date",cookie_date,expdate);
	document.write("Le site à subit des modifications depuis votre dernière visite!");
}

</SCRIPT>
bla
</body>

http://radeff.red/info/js/cookie-set.php

<HTML>
<!-- source: http://developer.irt.org/script/770.htm -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

var today = new Date();
var expires = new Date(today.getTime() + (56 * 86400000));
  
function set() {
    Set_Cookie("email",document.logonForm.email.value,expires);
}
//--></SCRIPT>
</HEAD>

<BODY>

<FORM NAME="logonForm" onSubmit="return set();">
<P>Email: <INPUT TYPE="INPUT" NAME="email">
<P><INPUT TYPE="RESET"> <INPUT TYPE="SUBMIT">
</FORM>
<hr>
<a href=cookie-check.php>cookie check</a>

</BODY>
</HTML>

date dernière modif

en JS pas super, vaut mieux du server-side

date=new Date(document.lastModified)
jour=date.getDate()
mois=date.getMonth()+1
annee=date.getFullYear()
if (annee<2000) {
annee=annee+100
}
document.write("<i>Last modified: " +jour +"/" +mois +"/" +annee + "</i>")

infobulles

kw: popup, survol texte boîte d'informations apparaissant lorsque l'on passe sur un texte

infobulles

Radio check

for (i=0;i<document.forms[0].radios.length;i++) {
	if (document.forms[0].radios[i].checked) {
		user_input = document.forms[0].radios[i].value;
	}
}

where radios is the name of the group of radio buttons.

check all (radio or checkbox)

en JS tout court

http://www.plus2net.com/javascript_tutorial/checkbox-checkall.php ++

Here is the code for single button. Here is the single function we use inside our head tags.

<SCRIPT LANGUAGE="JavaScript">
<!--

<!-- Begin
function Check(chk)
{
if(document.myform.Check_All.value=="Check All"){
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
document.myform.Check_All.value="UnCheck All";
}else{

for (i = 0; i < chk.length; i++)
chk[i].checked = false ;
document.myform.Check_All.value="Check All";
}
}

// End -->
</script>



Now the html part

<form name="myform" action="checkboxes.asp" method="post">
<b>Scripts for Web design and programming</b><br>
<input type="checkbox" name="check_list" value="1">ASP<br>
<input type="checkbox" name="check_list" value="2">PHP<br>
<input type="checkbox" name="check_list" value="3">JavaScript<br>
<input type="checkbox" name="check_list" value="4">HTML<br>
<input type="checkbox" name="check_list" value="5">MySQL<br>

<input type="button" name="Check_All" value="Check All"
onClick="Check(document.myform.check_list)">

</form>

http://www.webscriptexpert.com/Javascript/(un)check%20all%20checkboxes/

parfois ça suffit pas, ici un bout de script pour garantir que l'utilisateur a bien coché une case radio

	for (i=0;i<document.forms[0].Tarif.length;i++) {
	if (document.forms[0].Tarif[i].checked) {
		 user_input = document.forms[0].Tarif[i].value;
	
	 }
	}

	if(typeof(user_input)== "undefined"){
			 errors += "- Vous devez choisir un tarif\n";
	}

How to see panel when radio button selected

http://www.webdeveloper.com/forum/printthread.php?s=87f9267cc925893891baed668848f83f&threadid=41072

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

 "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">

<head>


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<meta name="Content-Script-Type" content="text/javascript">

<meta name="Content-Style-Type" content="text/css">




<script type="text/javascript">

<!--

onload = function () {document.getElementById('panel').className = 'hidden'}

// -->

</script>



<style type="text/css">

<!-- 


.hidden {visibility:hidden} 

-->

</style>



<title>Example</title>

</head>

<body>

<div><input type="checkbox" onclick="document.getElementById('panel').className = ''"></div>


<div id="panel">foo</div>

</body>

</html>

Images

image map

http://radeff.red/info/js/image_survolee1.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Document sans nom</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<img src="pics/kenya1.jpg" width="560" height="410" border="0" usemap="#Map">
<map name="Map">
  <area shape="rect" coords="15,9,40,36" href="save.html">
  <area shape="rect" coords="38,10,60,33" href="print.html">
  <area shape="rect" coords="58,9,82,36" href="mail.html">

  <area shape="rect" coords="79,10,109,33" href="bla.html">
</map>
</body>
</html>

image survolée

http://radeff.red/info/js/image_survolee.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Document sans nom</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>

<body onLoad="MM_preloadImages('pics/kenya1.jpg')">
<!--
PAS POSSIBLE DE MELANGER LES DEUX!!!
<map name="Map">
  <area shape="rect" coords="15,9,40,36" href="save.html">
  <area shape="rect" coords="38,10,60,33" href="print.html">
  <area shape="rect" coords="58,9,82,36" href="mail.html">
  <area shape="rect" coords="79,10,109,33" href="bla.html">
</map>

<a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('Kenya','','pics/kenya1.jpg',1)"><img
name="Kenya" border="0" src="pics/kenya.jpg" usemap="#Map"></a>
-->
<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Kenya','','pics/kenya1.jpg',1)"><img name="Kenya" border="0" src="pics/kenya.jpg"></a>
</body>
</html>

image_button

http://radeff.red/info/js/image_button.php

<form name="myForm" action='./'>
<input name="whatImage" type="hidden">
</form>

<a href="javascript:document.myForm.whatImage='image1';document.myForm.submit()"><img src="../../pics/good.gif" border=0></a><p>
<input type=image SRC="../../pics/WRITE.GIF">

Liens JS radeff

http://radeff.red/links/search.php?hp=1&disc=js

pour choisir dans un menu déroulant un lien et y aller http://radeff.red/info/js/formMenuJS.php

<SCRIPT LANGUAGE="JavaScript">
<!--
function goto_URL(object) {
    window.location.href = object.options[object.selectedIndex].value;
}
//-->
</SCRIPT>

<FORM>
<SELECT NAME="selectName" onChange="goto_URL(this.form.selectName)">
<OPTION VALUE="http://www.google.com/fr">Google
<OPTION VALUE="http://www.hotbot.com">HotBot
</SELECT>
</FORM>

nocopy

<script language="JavaScript">
function clique() {
if (event.button==2) {
alert('Le clique droit est interdit');
}
}
document.onmousedown=clique
</script>

<script type="text/javascript">
function selection(e)
{ return false; }
function clic()
{ return true; } 
document.onselectstart=new Function ("return false");
if (window.sidebar) {
  document.onmousedown=selection;
  document.onclick=clic;
 }
</script>

protection bidon qu'on peut contourner facilement en aspirant le site avec wget par exemple, ou en affichant le code source et en enlevant le html

http://radeff.red/info/js/popup.php

<script language="JavaScript"><!--
function windowOpener() {
   msgWindow=window.open("../../gif/good.gif","displayWindow","menubar=yes,scrollbars=yes,status=yes,width=300,height=300")
   msgWindow.document.write("<head><title>Message window<\/title><\/head>")
   for (var i=0; i < 10; i++)
       msgWindow.document.write('Message number ' + i + '<br>');
}
//--></script>

<form>
<input type="button" value="Message Window" onClick="windowOpener()">
</form>

<a href=javascript:windowOpener()>click here to open window</a>

popup2

http://radeff.red/info/js/popup2.php

<script type="text/javascript">
function openFullScreen(url) {
	  var x, y;
	    x = screen.width;
	      y = screen.height;
	        popup = window.open(url,'popup','top=0, left=0, location=yes, toolbar=yes, menubar=yes, status=yes, resizable=yes, scrollbars=yes, width='+x+', height='+y);
		  popup.focus();
	  }
	  </script>


	  Pour utiliser cette fonction dans un lien :

	  <a href="javascript:openFullScreen('http://www.unige.ch');">UniGE Website</a>

popup3

<body onload=javascript:windowOpener()>

<script language="JavaScript"><!--
function windowOpener(url,width,height) {
bla="toolbar=0,location=0,top=0,left=0,status=0,menubar=0,scrollbars=0,resizable=0,width="
+ +",height=" +";
msgWindow=window.open(http://www.pyrotechnic.ch/2004%20Turin/Grandes%20images/GHpim6225.jpg,'Image',bla);
}
//--></script>
<!-- <a href=javascript:windowOpener("http://www.pyrotechnic.ch/2004%20Turin/Grandes%20images/GHpim6225.jpg",469,623)>click here to open window</a>
-->

Pour ecrire un message de statut (scroll-effect)

http://radeff.red/info/js/scroll.html

<html>
<head>
<script>
Texte="Pour ecrire un <html><a href='test.htm'>message de statut</a> (scroll-effect)<html>"
longueur=Texte.length
pos=-longueur
function defil() {
var affiche=""
pos=pos+1
if (pos==longueur) {
pos=-pos
}
if (pos<0) {
for (var i=1; i<=-pos; i++) {
affiche=affiche+" "
}
affiche=affiche+Texte.substring(0,longueur-i+1)
}
else {
affiche=affiche+Texte.substring(pos,longueur+pos)
}
window.status=affiche
setTimeout("defil()",100)
}
</script>
</head>
<body onLoad="defil()">
Pour ecrire un message de statut (scroll-effect)
</body>
</html>

quiz

http://radeff.red/info/js/STRESS_PERCU.html

<SCRIPT LANGUAGE="JavaScript1.1">
function letotal() {
total=parseInt(document.getElementById('q1').options[document.getElementById('q1').selectedIndex].value);
total+=parseInt(document.getElementById('q2').options[document.getElementById('q2').selectedIndex].value);
total+=parseInt(document.getElementById('q3').options[document.getElementById('q3').selectedIndex].value);
total+=parseInt(document.getElementById('q4').options[document.getElementById('q4').selectedIndex].value);
total+=parseInt(document.getElementById('q5').options[document.getElementById('q5').selectedIndex].value);
total+=parseInt(document.getElementById('q6').options[document.getElementById('q6').selectedIndex].value);
total+=parseInt(document.getElementById('q7').options[document.getElementById('q7').selectedIndex].value);
total+=parseInt(document.getElementById('q8').options[document.getElementById('q8').selectedIndex].value);
total+=parseInt(document.getElementById('q9').options[document.getElementById('q9').selectedIndex].value);
total+=parseInt(document.getElementById('q10').options[document.getElementById('q10').selectedIndex].value);
document.quiz.total.value=total;
}

function feedback() {
total=document.quiz.total.value;
if(total<=10) {
alert("Vous vous sentez peu ou pas stressé");
} else if(total>10&&total<=20) {
alert("Vous vous sentez un peu stressé");
} else if(total>20&&total<=30) {
alert("Vous vous sentez assez stressé");
} else if(total>30) {
alert("Vous vous sentez très stressé");
}

}
</SCRIPT>
<!-- see webpage source code for details -->

right click handler qui tourne sous IE et Firefox

<script language="JavaScript">
<!--
function mouseDown(e) {
if (parseInt(navigator.appVersion)>3) {
 var clickType=1;
 if (navigator.appName=="Netscape") clickType=e.which;
 else clickType=event.button;
 if (clickType==1) self.status='Left button!';
 if (clickType!=1) self.status='Right button!';
}
return true;
}
if (parseInt(navigator.appVersion)>3) {
document.onmousedown = mouseDown;
if (navigator.appName=="Netscape")
 document.captureEvents(Event.MOUSEDOWN);
}
//-->
</script>

Table CharCode

caractères codes calculés avec js

todo!

Vérifier form + email avec js

http://radeff.red/info/js/form_check_email_regexp_js.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="http://www.unige.ch/UDK/scripts/contenu.css">
<script language="JavaScript" src="http://www.unige.ch/UDK/scripts/dom.js"></script>
 
<script language="javascript">
<!--
function envoi() {
  var erreur = "";
   if (document.forms[0].nom.value == "") {
      erreur += "- Vous devez entrer votre nom SVP.\n";
    }
  if (document.forms[0].prenom.value == "") {
      erreur += "- Vous devez entrer votre prénom SVP.\n";
    }
  if (document.forms[0].faculte.value == "") {
      erreur += "- Vous devez entrer votre faculté SVP.\n";
    }
  if (document.forms[0].date_de_naissance.value == "") {
      erreur += "- Vous devez entrer votre date de naissance SVP.\n";
    }
  if (document.forms[0].adresse.value == "") {
      erreur += "- Vous devez entrer votre adresse SVP.\n";
    }
  if (document.forms[0].npa.value == "") {
      erreur += "- Vous devez entrer votre npa SVP.\n";
    }
  if (document.forms[0].localite.value == "") {
      erreur += "- Vous devez entrer votre localite SVP.\n";
    }
email=document.forms[0].email.value;
   if ( email == "" )
      erreur += "- Vous devez entrer votre email SVP.\n";
   else
   {
      if ( ( email.indexOf("@") == -1 ) || ( email.indexOf("@") == 0 ) || ( email.indexOf("@") != email.lastIndexOf("@") ) || ( email.indexOf(".") == email.indexOf("@")-1 ) || ( email.indexOf(".") == email.indexOf("@") +1 ) || ( email.indexOf("@") == email.length -1 ) || ( email.indexOf (".") == -1 ) || ( email.lastIndexOf (".") == email.length -1 ) )
      erreur += "- Votre email est incorrect.\n";
 
   }
  if (erreur != "") {
    alert(erreur+"\nVeuillez corriger le formulaire svp.");
    return false;
  } else {
    return true;
  }
}
//-->
</script>
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<meta http-equiv="expires" content="0">
<meta name="revisit-after" content="28 days">
<meta http-equiv="Reply-to" content="antenne-sante@unige.ch">
<meta name="Author" content="Copyright © Mars 2001 - Nancy Rieben - Université de Genève">
<meta name="Title" content="UniGE - Antenne santé - inscription">
 
<meta name="description" content="inscription on line pour les cours de sophrologie"> 
<meta name="keywords" lang="fr" content="étudiants, santé">
<title>UniGE - Antenne santé - inscription</title>
</head>
<body marginwidth="0" marginheight="0"  topmargin="0" leftmargin="0" bgcolor="white">
<script language="JavaScript1.2" type="TEXT/JAVASCRIPT">decale();</script>
<script language="JavaScript1.2" type="TEXT/JAVASCRIPT">logoPrint(true);</script>
 
 
<table cellspacing="0" border="0" cellpadding="0" width="522">
  <tr> 
    <td colspan="3" valign="top" class="justify"><br>
 
      <div align="center">
 
        <p><span class="moyenrougeb"> R&eacute;serv&eacute; aux &eacute;tudiants de l'Universit&eacute; et des HES</span></p>
        </div>
      <p align="center"> <img src="pics/online.gif" width="120" height="15"> 
      <p align="center"> merci de remplir tous les champs </p>
 
      <form action="" method="post" OnSubmit="return envoi()">
        <table width="100%" border="0">
          <tr> 
            <td width="48%" align="center" valign="middle"> 
              <div align="left">Cours 
                de </div>
            </td>
            <td width="52%" align="center" valign="baseline"> 
              <div align="left">mardi 12h30 
                <input type="radio" name="cours" value="mardi 12h15" checked>
                mercredi 18h15 
                <input type="radio" name="cours" value="mercredi 18h15">
 
              </div>
            </td>
          </tr>
          <tr> 
            <td width="48%">Nom</td>
            <td width="52%"> 
              <input type="text" name="nom" value=>
            </td>
          </tr>
 
          <tr> 
            <td width="48%">Pr&eacute;nom</td>
            <td width="52%"> 
              <input type="text" name="prenom">
            </td>
          </tr>
          <tr> 
            <td width="48%">Facult&eacute; 
              ou &eacute;cole</td>
 
            <td width="52%"> 
              <input type="text" name="faculte">
            </td>
          </tr>
 
          <tr> 
            <td width="48%">Date 
              de naissance</td>
            <td width="52%"> 
              <input type="text" name="date_de_naissance">
            </td>
 
          </tr>
 
          <tr> 
            <td width="48%">Adresse 
              priv&eacute;e</td>
            <td width="52%"> 
              <input type="text" name="adresse">
            </td>
          </tr>
          <tr> 
            <td width="48%">Code postal</td>
 
            <td width="52%"> 
              <input type="text" name="npa" size="10">
            </td>
          </tr>
          <tr> 
            <td width="48%">Localit&eacute;</td>
            <td width="52%"> 
              <input type="text" name="localite">
            </td>
          </tr>
 
          <tr> 
            <td width="48%">T&eacute;l&eacute;phone </td>
            <td width="52%"> 
              <input type="text" name="telephone">
            </td>
          </tr>
          <tr> 
            <td width="48%">E-mail</td>
 
            <td width="52%"> 
              <input type="text" name="email">
            </td>
          </tr>
          <tr> 
            <td width="48%"></td>
            <td width="52%">&nbsp;</td>
          </tr>
          <tr> 
            <td height="36" width="48%">
 
                <input type="reset" name="Submit" value="Effacer">
          </td>
            <td height="36" width="52%"> 
              <div align="right">
              <input type="submit" name="Submit" value="Envoyer">
 
               </div>
            </td>
          </tr>
        </table>
 
      </form>
            </td>
  </tr>
</table>
<table cellspacing="0" border="0" cellpadding="0" width="522" height="">
  <tr> 
    <td colspan="3" class="justify" height="">
      <div align="center"></div>
    </td>
  </tr>
 
  <tr> 
    <td width="514" height="17">&nbsp;</td>
    <td width="1" height="17">&nbsp;</td>
    <td width="8" height="17">&nbsp;</td>
  </tr>
</table>
<!--NE MODIFIER QUE L'ADRESSE E-MAIL ET LE SUBJECT (si nécessaire) DANS LES LES LIGNES CI-DESSOUS-->
</body>
</html>

Vérifier un formulaire avant envoi (checkform)

http://radeff.red/info/js/checkform.phps

Calculer la somme de plusieurs champs (additions)

Calculer la somme de plusieurs champs (additions) avec js

Caractères accentués

pour changer (“désaccentuer”) des caractères avec JS:

annuaire=document.forms[0].q.value;
annuaire=annuaire.replace("à","a");
annuaire=annuaire.replace("â","a");
annuaire=annuaire.replace("ç","c");
annuaire=annuaire.replace("é","e");
annuaire=annuaire.replace("é","e");
annuaire=annuaire.replace("é","e");
annuaire=annuaire.replace("è","e");
annuaire=annuaire.replace("ê","e");
annuaire=annuaire.replace("î","i");
annuaire=annuaire.replace("ô","o");
annuaire=annuaire.replace("ò","o");
annuaire=annuaire.replace("û","u");
annuaire=annuaire.replace("ù","u");
  • info/js.txt
  • Dernière modification: 2019/06/19 10:08
  • par radeff