| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Sep 2005 Location: At Home
Posts: 881
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Tell a friend script OK, I have this so far: Code: <script type='text/javascript'>
function showField(div_name)
{
var txt = "";
var num = document.form1.item_count.value;
for(i = 0; i < num; i++)
{
txt += "<input type='text' name='friendname_" + i + "' value='name' onfocus='this.value='''/></input><input type='text' name='friendemail_" + i + "' value='email'/><br /></input>";
}
document.getElementById(div_name).innerHTML = txt;
}
function showDropDown()
{
if(document.form1.checkbox_name.checked == true)
{
document.getElementById('dropdown').style.display = "block";
}
else
{
document.getElementById('dropdown').style.display = "none";
document.getElementById('email_div').innerHTML = null;
}
}
</script> ????: NamePros.com http://www.namepros.com/programming/184422-tell-a-friend-script.html s there a way of resetting the value of the drop down menue when it is hidden? Also why doesn't it show the textbox tag in the html of the file when it is showing them? Have a look at this site to see it in action: http://asgsoft.net/petition/tellafriend.php?id=1 PLEASE TICK THE BOX TO START. Thanks for the help in advance
__________________ |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Aug 2005 Location: NY, USA
Posts: 608
![]() ![]() ![]() ![]() ![]() ![]() | >>How can I make the textboxes empty when you click on them? add this inside the input tags: onclick="this.value='';" >>Is there a way of resetting the value of the drop down menue when it is hidden? find this line: dcument.getElementById('dropdown').style.display = "none"; add after: dcument.getElementById('dropdown').value= ""; >>Also why doesn't it show the textbox tag in the html of the file when it is showing them? Because the code isn't a part of the html file. It's generated by the javascript seperately.
__________________ ask me about the internet |
| |
| | THREAD STARTER #3 (permalink) | ||||||||
| NamePros Regular Join Date: Sep 2005 Location: At Home
Posts: 881
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
????: NamePros.com http://www.namepros.com/showthread.php?t=184422
__________________ | ||||||||
| |
| | #4 (permalink) |
| NamePros Regular Join Date: Aug 2005 Location: NY, USA
Posts: 608
![]() ![]() ![]() ![]() ![]() ![]() | txt += "<input type='text' name='friendname_" + i + "' value='name' onfocus=\"this.value='';\" /></input><input type='text' name='friendemail_" + i + "' value='email' onfocus=\"this.value='';\" /><br /></input>"; That should work. As long as the div that you're printing the tags into is enclosed in <form> tags, it should be able to post to a php page just fine.
__________________ ask me about the internet |
| |
| | THREAD STARTER #6 (permalink) |
| NamePros Regular Join Date: Sep 2005 Location: At Home
Posts: 881
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | here is my email validation script: ????: NamePros.com http://www.namepros.com/showthread.php?t=184422 Code: <script language = "Javascript">
function echeck(str) {
var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
alert("Invalid E-mail Address")
return false
}
if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
alert("Invalid E-mail Address")
return false
}
if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
alert("Invalid E-mail Address")
return false
}
if (str.indexOf(at,(lat+1))!=-1){
alert("Invalid E-mail Address")
return false
}
if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
alert("Invalid E-mail Address")
return false
}
if (str.indexOf(dot,(lat+2))==-1){
alert("Invalid E-mail Address")
return false
}
if (str.indexOf(" ")!=-1){
alert("Invalid E-mail Address")
return false
}
return true
}
__________________ |
| |
| | #7 (permalink) |
| NamePros Regular Join Date: Aug 2005 Location: NY, USA
Posts: 608
![]() ![]() ![]() ![]() ![]() ![]() | add this function along with that email validation function: Code: function checkall() {
var check = true;
var num = document.form1.item_count.value;
for(i = 0; i < num; i++) {
eval("check = echeck(friendemail_' + i + ');");
if(check==false) return false;
}
return true;
} Should work. Haven't tested it.
__________________ ask me about the internet |
| |
| | THREAD STARTER #8 (permalink) |
| NamePros Regular Join Date: Sep 2005 Location: At Home
Posts: 881
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | it doesn't seem to work. Look at http://asgsoft.net/petition/tellafriend.php?id=2 to see it in action
__________________ |
| |