Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Wednesday, April 01, 2009

Troubles calling form.submit()

Apparently you can't have an element with an id of submit in a form and call form.submit()

It will try calling that element as a function rather than invoking the form.submit method


<form onsubmit="agree();return false;">



<div class="buttons">

<input type="submit" name="iAgree" id="iAgree" value="I Agree" class="button" />

<input type="button" name="disAgree" id="disAgree" value="Cancel" class="button" onClick="tb_remove();" />

</div>

</form>
agree is not a function
<input type="submit" name="agree" id="agree" value="I Agree" class="button" />

so if the form has an element named agree
agree is not a valid function name in the onsubmit
weird

Thursday, December 27, 2007

Get text of select box

var Foo= document.getElementById("selectid").options[document.getElementById("selectid").options.selectedIndex].text;

javascript for disabling links


<style>


a.disabled {cursor: default;color: #ccc;text-decoration: none;}


</style>


<script type="text/javascript">


var linkids=["href800 Series1","href1000 Series4","href1200 Series8"]


function activLink(b){


for (var i=0; i<linkids.length; i++){


                document.getElementById(linkids[i]).onclick=function(){return b}


                document.getElementById(linkids[i]).disabled=!b


                }


}


window.onload = function() {


activLink(false);


}


function activLink(b){


for (var i=0; i<linkids.length; i++){


                var thisLink = document.getElementById(linkids[i]);


                thisLink.onclick = function() { return b }


                thisLink.className = (b == true) ? '' : 'disabled';


                }


}


</script>


 


This javascript will disable links with the ids in the list


Thursday, July 19, 2007

JavaScript Validation Thing

Just a little validation JavaScript function in case anyone else needs it. yes it was for some coldfusion, but no you I am not going to make it more generalized.
function ValidateDate(theDate)
{
EnteredDate = new Date(theDate).toDateString();
EffDate = new Date("#DateFormat(getARD.IPI_EffectiveDate,'mm/dd/yyyy')#"). toDateString(); PrevDate = new Date("#DateFormat(DateAdd('yyyy',-1,getArd.IPI_EffectiveDate), 'mm/dd/yyyy')#").toDateString();

if(Date.parse(EnteredDate) < Date.parse (EffDate) && Date.parse(EnteredDate) > Date.parse(PrevDate))
{
return true;
}else{
alert('Date must be less than the effective date of the policy and no more than a year before the effective date.');
$('Anniversary_Rating_Date').value = '';
}
}