Jump to content


Photo

Some Javascript help


  • Please log in to reply
2 replies to this topic

#1 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 31 March 2006 - 07:49 PM

I need to have a dynamic javascript that can work on nearly all platforms.

Basicly you have a check box that says tell a friend. When you check it it shows a drop menu asking the number of friends (Max of 6)

It should display textboxes repeated by the number chosen to enter email address.

I will be putting an email validating script on all textboxes.


How can I acheive that?

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips


#2 asgsoft

asgsoft
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts

Posted 05 April 2006 - 06:10 PM

OK, I have this so far:
<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: [a href=\"http://asgsoft.net/petition/tellafriend.php?id=1\" target=\"_blank\"]http://asgsoft.net/petition/tellafriend.php?id=1[/a]

PLEASE TICK THE BOX TO START.

Free SEO and Domain tools |HTML ENT| Your Source to expired domains with PageRank & tips


#3 Vorotaev

Vorotaev
  • Members
  • PipPip
  • Member
  • 27 posts
  • LocationCanada

Posted 06 April 2006 - 06:26 PM

[!--quoteo(post=362010:date=Apr 5 2006, 02:40 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 5 2006, 02:40 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
How can I make the textboxes empty when you click on them?

Is 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?
[/quote]

Question 1:
Add onfocus="this.value=''" to the input fields to make them clear when someone clicks on them, or uses the tab key to navigate to them. Please note the use of " and '; you must use alternating quotations, or the form will think the first ' after the = is the closing '.

Question 2:
document.getElementById('item_count').options['[!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]ID[!--colorc--][/span][!--/colorc--]'].selected=true

Please notice the highlighted "ID" in the above code. You need to assign the <option> the menu resets to an ID, and place it where shown.

Question 3:
The HTML source only shows what was there when the page was compiled. Any changes to the code by Javascript after that will not appear in the source code.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users