Unstoppable Domains

Tell a friend script

Spaceship Spaceship
Watch

asgsoft

VIP Member
Impact
9
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>

How can I make the textboxes empty when you click on them?

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
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
>>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.
 
0
•••
Jim_ said:
>>How can I make the textboxes empty when you click on them?

add this inside the input tags: onclick="this.value='';"
This is part of a variable and so it will not work

Jim_ said:
>>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.

Is there a way to make it part of the document because i need to be able to send their values via php
 
0
•••
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.
 
1
•••
your the man. It works, I don't know how to thank you :)

how can i validate email address?
 
0
•••
here is my email validation script:

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					
	}
 
0
•••
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;
}

then add onsubmit="checkall();" to the <form> tag.

Should work. Haven't tested it.
 
0
•••
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back