Jump to content

Archived

This topic is now archived and is closed to further replies.

asgsoft

Some Javascript help

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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>

[/code]

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.

Share this post


Link to post
Share on other sites
[!--quoteo(post=362010:date=Apr 5 2006, 02:40 PM:name=asgsoft)--][div class=\'quotetop\']QUOTE(asgsoft @ Apr 5 2006, 02:40 PM) [snapback]362010[/snapback][/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 [b]onfocus="this.value=''"[/b] 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 [u]must[/u] use alternating quotations, or the form will think the first ' after the = is the closing '.

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

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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.