<html>
<head>
<title>Multiple Form Multiple Submit Buttons - RJM Programming - February, 2015</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href='//www.rjmprogramming.com.au/PHP/emboss_h1.css' rel='stylesheet' type='text/css'>
<script type='text/javascript'>
var ans='';
var oif=null;
var odiv=null;
function istrip(duis) {
var rect, newx=0.0, newy=0.0, ertw;
if (duis.indexOf('.x=') != -1) {
//alert('0:' + document.URL);
var afterbit=document.URL.split('&submit')[1].split('.')[0].split('=')[0];
if (window.parent) {
if (parent.document.getElementById('submit' + (location.search.split('form=')[1] ? (decodeURIComponent(location.search.split('form=')[1]).split('&')[0]) : 'myform1').replace('myform','') + afterbit)) {
rect=parent.document.getElementById('submit' + (location.search.split('form=')[1] ? (decodeURIComponent(location.search.split('form=')[1]).split('&')[0]) : 'myform1').replace('myform','') + afterbit).getBoundingClientRect();
newx+=rect.left;
newy+=eval((eval('' + rect.top) - eval('' + rect.height)));
newx+=eval(duis.split('.x=')[1].split('&')[0].split('.')[0].replace('px',''));
newy+=eval(duis.split('.y=')[1].split('&')[0].split('.')[0].replace('px',''));
//alert(document.URL + ' ... <p style="position:absolute;left:' + Math.round(newx) + 'px;top:' + Math.round(newy) + 'px;">x</p>');
//alert('00:' + document.URL);
parent.document.getElementById('submit' + (location.search.split('form=')[1] ? (decodeURIComponent(location.search.split('form=')[1]).split('&')[0]) : 'myform1').replace('myform','') + afterbit).style.border='1px solid red';
try {
//document.body.innerHTML+='<p style="color:red;z-index:65;position:absolute;left:' + Math.round(newx) + 'px;top:' + Math.round(newy) + 'px;">x</p>';
parent.document.getElementById('dlast').innerHTML+='<p style="color:red;z-index:65;position:absolute;left:' + Math.round(newx) + 'px;top:' + Math.round(newy) + 'px;">x</p>';
} catch (ertw) {
}
//alert('000:' + document.URL);
}
} else {
rect=document.getElementById('submit' + (location.search.split('form=')[1] ? (decodeURIComponent(location.search.split('form=')[1]).split('&')[0]) : 'myform1').replace('myform','') + afterbit).getBoundingClientRect();
newx+=rect.left;
newy+=eval((eval('' + rect.top) - eval('' + rect.height))); //rect.top;
newx+=eval(duis.split('.x=')[1].split('&')[0].split('.')[0].replace('px',''));
newy+=eval(duis.split('.y=')[1].split('&')[0].split('.')[0].replace('px',''));
//alert(document.URL + ' ... <p style="position:absolute;left:' + Math.round(newx) + 'px;top:' + Math.round(newy) + 'px;">x</p>');
//document.body.innerHTML+='<p style="color:red;z-index:65;position:absolute;left:' + Math.round(newx) + 'px;top:' + Math.round(newy) + 'px;">x</p>';
document.getElementById('dlast').innerHTML+='<p style="color:red;z-index:65;position:absolute;left:' + Math.round(newx) + 'px;top:' + Math.round(newy) + 'px;">x</p>';
//alert('2:' + document.URL);
}
}
//alert(document.URL);
return duis.replace(/\.x\=/g,'=').replace(/\.y\=/g,'=');
}
function cif() {
oif=document.getElementById('mycif'); //'myif');
if (oif != null) {
oif.style.display='block';
odiv=document.getElementById('mydiv');
if (odiv) { odiv.style.display='none'; }
}
}
function checkurl() {
var rect;
oif=document.getElementById('mycif'); //'myif');
if (oif != null) {
var oform;
for (var i=1; i<=4; i++) {
eval("oform=document.getElementById('myform" + i + "')");
oform.target='mycif'; //'myif';
}
}
if (istrip(document.URL).indexOf('ask=') != -1) {
ans = prompt("What is the answer to my question?", "");
document.body.innerHTML = "<h1 align='center'>Your answer to the question is ... " + ans + "</h1><br><br>" + document.body.innerHTML;
} else if (istrip(document.URL).indexOf('email=') != -1) {
document.body.innerHTML += '<a style="display:none;" id="aemail" href="mail' + 'to:?subject=My%20Email%20Question%20to%20you" title="Email">Email</a>';
document.getElementById('aemail').click();
} else if (istrip(document.URL).indexOf('iframe=') != -1) {
var mydate = new Date();
document.body.innerHTML = "<h1 align='center'>We'll proceed in an iframe below ... " + mydate + "</h1><br><br><iframe name='myif' id='myif' src='./multiple_form_multiple_submit_buttons.html' style='width:100%;height:1200px;display:none;'></iframe><div id='mydiv' align='center' style='display:block;'>" + document.body.innerHTML + "</div>";
} else if (istrip(document.URL).indexOf('?') != -1) {
alert('This is your usual scenario. Sorry to interrupt, but it really is normal.' + document.URL);
} //else {
//alert('Why? ' + istrip(document.URL) + ' vs ' + document.URL);
//}
var inps=document.getElementsByTagName('input');
for (var jnps=0; jnps<inps.length; jnps++) {
rect=inps[jnps].getBoundingClientRect();
inps[jnps].style.width=('' + rect.width).replace('px','') + 'px';
inps[jnps].style.height=('' + rect.height).replace('px','') + 'px';
}
if (document.URL.indexOf('mode=image') != -1) {
//document.getElementById('stype').value='image';
toggleit('image ');
}
}
function toggleit(sval) {
var rect, inps, jnps,pfound=false;
document.getElementById('stype').value=sval.trim();
sval=sval.trim();
document.getElementById('mode1').value=sval;
document.getElementById('mode2').value=sval;
document.getElementById('mode3').value=sval;
document.getElementById('mode4').value=sval;
if (sval.toLowerCase() == 'image') {
document.getElementById('bigdiv').innerHTML=document.getElementById('bigdiv').innerHTML.replace(/type\=\'submit\'/g, "type='image' formmethod='GET' src='//www.rjmprogramming.com.au/MyBusinessUnidad/Welcome_files/logo.jpg'").replace(/type\=\"submit\"/g, 'type="image" formmethod="GET" src="//www.rjmprogramming.com.au/MyBusinessUnidad/Welcome_files/logo.jpg"').replace(/type\=submit/g, "type=image formmethod='GET' src='//www.rjmprogramming.com.au/MyBusinessUnidad/Welcome_files/logo.jpg'");
if (window.parent) {
//inps=parent.document.getElementsByTagName('p');
inps=document.getElementsByTagName('p');
for (jnps=0; jnps<inps.length; jnps++) {
inps[jnps].style.visibility='visible';
pfound=true;
}
//inps=parent.document.getElementsByTagName('input');
inps=document.getElementsByTagName('input');
for (jnps=0; jnps<inps.length; jnps++) {
if (inps[jnps].type == 'image') {
rect=inps[jnps].getBoundingClientRect();
if (!pfound) {
//parent.document.getElementById('bigdiv').innerHTML+='<p onclick="event.stopPropagation(); document.getElementById(' + "'" + inps[jnps].id + "'" + ').click();" style="cursor:pointer;font-size:10px;position:absolute;left:' + ('' + rect.left).replace('px','') + 'px;top:' + eval(eval(('' + rect.top).replace('px','')) - eval(('' + rect.height).replace('px','')) / 5) + 'px;">' + inps[jnps].value + '</p>';
document.getElementById('bigdiv').innerHTML+='<p onclick="event.stopPropagation(); document.getElementById(' + "'" + inps[jnps].id + "'" + ').click();" style="cursor:pointer;font-size:10px;position:absolute;left:' + ('' + rect.left).replace('px','') + 'px;top:' + eval(eval(('' + rect.top).replace('px','')) - eval(('' + rect.height).replace('px','')) / 5) + 'px;">' + inps[jnps].value + '</p>';
}
inps[jnps].style.width=('' + rect.width).replace('px','') + 'px';
inps[jnps].style.height=('' + rect.height).replace('px','') + 'px';
}
}
}
} else {
document.getElementById('bigdiv').innerHTML=document.getElementById('bigdiv').innerHTML.replace(/type\=\'image/g, "type='submit").replace(/type\=\"image/g, 'type="submit').replace(/type\=image/g, "type=submit");
inps=document.getElementsByTagName('p');
for (jnps=0; jnps<inps.length; jnps++) {
inps[jnps].style.visibility='hidden';
}
}
}
</script>
</head>
<body onload=' checkurl(); ' style='background-color:pink;'>
<h1 align='center'>Multiple Form Multiple <select id=stype onchange=toggleit(this.value);><option value=submit>Submit</option><option value=image>Image</option></select> Buttons</h1>
<div id=bigdiv align='center' style='background-color: yellow;'>
<form style='height:50px;background-color: green;float:top;' method='GET' action='./multiple_form_multiple_submit_buttons.html' id='myform1' target='mycif'>
<br><input type=hidden name=form value=myform1></input><input type=hidden id=mode1 name=mode value=submit></input><input type='submit' title='Normal submit of form' onclick='cif();' name='submit' id='submit' value='Validate'></input>
<input type='reset' title='Clear the decks and start again' id='reset' value='Reset' onclick=" top.window.location.href='./multiple_form_multiple_submit_buttons.html'; "></input>
<input type='submit' title='Submit of form with email intervention' onclick='cif();' name='submitemail' id='submit1email' value='Validate and Email'></input>
<input type='submit' title='Submit of form with interactive prompting' onclick='cif();' name='submitask' id='submit1ask' value='Validate and Ask'></input>
<input type='submit' title='Submit of form to an embedded iframe' onclick='cif();' name='submitiframe' id='submit1iframe' value='Validate and Iframe'></input>
</form>
<br><br>
<form style='height:180px;background-color: purple;float:right;' method='GET' action='./multiple_form_multiple_submit_buttons.html' id='myform2' target='mycif'>
<br><input type=hidden name=form value=myform2></input><input type=hidden id=mode2 name=mode value=submit></input><input type='submit' title='Submit of form with email intervention' onclick='cif();' name='submitemail' id='submitemail' value='Validate and Email'></input>
<br><input type='reset' title='Clear the decks and start again' id='reset' value='Reset' onclick=" top.window.location.href='./multiple_form_multiple_submit_buttons.html'; "></input>
<br><input type='submit' title='Normal submit of form' onclick='cif();' name='submit' id='submit2' value='Validate'></input>
<br><input type='submit' title='Submit of form with interactive prompting' onclick='cif();' name='submitask' id='submit2ask' value='Validate and Ask'></input>
<br><input type='submit' title='Submit of form to an embedded iframe' onclick='cif();' name='submitiframe' id='submit2iframe' value='Validate and Iframe'></input>
</form>
<form style='height:180px;background-color: orange;float:left;' method='GET' action='./multiple_form_multiple_submit_buttons.html' id='myform3' target='mycif'>
<br><input type=hidden name=form value=myform3></input><input type=hidden id=mode3 name=mode value=submit></input><input type='submit' title='Submit of form with interactive prompting' onclick='cif();' name='submitask' id='submitask' value='Validate and Ask'></input>
<br><input type='reset' title='Clear the decks and start again' id='reset' value='Reset' onclick=" top.window.location.href='./multiple_form_multiple_submit_buttons.html'; "></input>
<br><input type='submit' title='Normal submit of form' onclick='cif();' name='submit' id='submit3' value='Validate'></input>
<br><input type='submit' title='Submit of form with email intervention' onclick='cif();' name='submitemail' id='submit3email' value='Validate and Email'></input>
<br><input type='submit' title='Submit of form to an embedded iframe' onclick='cif();' name='submitiframe' id='submit3iframe' value='Validate and Iframe'></input>
</form>
<iframe id='mycif' name='mycif' src='./multiple_form_multiple_submit_buttons.html' style='width:70%;height:400px;background-color: pink;'></iframe>
<br><br>
<form style='height:50px;background-color: blue;float:bottom;' method='GET' action='./multiple_form_multiple_submit_buttons.html' id='myform4' target='mycif'>
<br><input type=hidden name=form value=myform4></input><input type=hidden id=mode4 name=mode value=submit></input><input type='submit' title='Submit of form to an embedded iframe' onclick='cif();' name='submitiframe' id='submitiframe' value='Validate and Iframe'></input>
<input type='reset' title='Clear the decks and start again' id='reset' value='Reset' onclick=" top.window.location.href='./multiple_form_multiple_submit_buttons.html'; "></input>
<input type='submit' title='Normal submit of form' onclick='cif();' name='submit' id='submit4' value='Validate'></input>
<input type='submit' title='Submit of form with email intervention' onclick='cif();' name='submitemail' id='submit4email' value='Validate and Email'></input>
<input type='submit' title='Submit of form with interactive prompting' onclick='cif();' name='submitask' id='submit4ask' value='Validate and Ask'></input>
</form>
</div>
<div id=dlast></div>
</body>
</html>