Jump to content

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?
Link to comment
https://forums.phpfreaks.com/topic/6294-some-javascript-help/
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.
Link to comment
https://forums.phpfreaks.com/topic/6294-some-javascript-help/#findComment-24250
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.
Link to comment
https://forums.phpfreaks.com/topic/6294-some-javascript-help/#findComment-24545
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.