| | |||||
| ||||||||
| 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
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Show and hide a textfield based on a selectbox I am using this JS to show and hide a textbox when the value for the select box changes. It shows the textbox alright, but when I want to hide it it won't. Here is what I have: Code: function showField(email_div)
{
var txt = "";
if(document.form1.type.value = "Banner Impressions")
{
txt += "<p>Banner Location:<input type='text' name='bannerloc' value='<?php echo $firstname; ?>' onfocus=\"this.value='';\" /></p>";
document.getElementById(email_div).innerHTML = txt;
}
else
{
txt = null;
document.getElementById(email_div).innerHTML = nill;
}
}
__________________ |
| |
| | #2 (permalink) |
| Senior Member Join Date: Dec 2006 Location: England
Posts: 1,568
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Hi asgsoft. Can i assume email_div is the layer you wish to hide? Technically you are not hiding anything here, in affect you are you are removing it. Remember that is is null not nill btw ![]() PHP Code: |
| |
| | #5 (permalink) |
| NamePros Regular Join Date: May 2005 Location: England
Posts: 392
![]() ![]() ![]() | Code: function showField(email_div)
{
if(document.form1.type.value = "Banner Impressions")
{
var txt = '<p>Banner Location:<input type="text" name="bannerloc" value="<?php echo $firstname; ?>" onfocus="this.value=\'\';" /></p>';
document.getElementById(email_div).innerHTML = txt;
document.getElementById(email_div).style.display = 'block';
}
else
{
document.getElementById(email_div).style.display = 'none';
}
}
__________________ -Beaver6813.com - Web Developer Extraordinaire! |
| |
| | #7 (permalink) |
| Senior Member Join Date: Dec 2006 Location: England
Posts: 1,568
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Right that helped ![]() Look at your option again: Code: <option value="banner">Banner Impressions</option> Code: if(document.form1.type.value = "Banner Impressions") Code: if(document.form1.type.value == "banner") PHP Code: |
| |
| | THREAD STARTER #8 (permalink) |
| NamePros Regular Join Date: Sep 2005 Location: At Home
Posts: 881
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | thanks a lot. That's fixed now. Can you have a look at the price section? http://asgsoft.net/form/form.php It should make the price change, it only works when i have one price set, when I have all of them then it doesn't work. Where have i gone wrong?
__________________
Last edited by asgsoft; 01-03-2007 at 09:00 AM.
|
| |