Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-17-2012, 12:34 PM   PM User | #1
SACoder
New to the CF scene

 
Join Date: Aug 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
SACoder is an unknown quantity at this point
OnChange issue found when used in conjunction with innerHTML

Hey Guys,

I was wondering if anyone could solve the issue I am currently having.

I am attempting to create a text box using innerHTML between div tags when the value of a scroll down box is 0.

Here stands my code:

Code:
<select name="destination" onchange="dest(document.signoutForm.destination.options[document.signoutForm.destination.selectedIndex].value);">
Code:
function dest(destination){
	if(destination == 0){document.getElementById("demo").innerHTML="<input type=\"text\" name=\"dest\" />";
	}else {
		document.getElementById("demo").innerHTML=" ";
	}
}
I have attempted changing the function which calls the method (i.e. to onclick, onkeyup, etc.) but alas, no success.

The textbox is created when the destination is == 0 however once the function has been called and the text box been created, the function is not called again (I have tested this with various alert message placed throughout the code).

Anyone have any idea what I can do to solve the issue.

Thanks

SACoder
SACoder is offline   Reply With Quote
Old 08-17-2012, 12:49 PM   PM User | #2
Dadaso
New to the CF scene

 
Join Date: Aug 2012
Location: Thane
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Dadaso is an unknown quantity at this point
hi everyone ,
i face following problem. in IE it works but problem in firefox .

in xsl file :<IMG name="img_start_date" id="Detail1.{normalize-space($dbID)}.start_date__img" src="/ibase/scheduler/images/table.gif" style="width=15;height=15;" onClick="showCalendar(this);" value="{$start_date}" ISCHANGED="false" />
---------------------------------------------------------------------------------------------------------------------------
in js file :
var curFieldName = obj.id;

fldName = curFieldName.substring(0, curFieldName.indexOf("__img") );

obj1 = document.getElementById(fldName);
alert("field name : "+obj1);
oldDate = obj1.value;
show_calendar();

value of the oldDate is null in firefox and in IE display date

ple'z reply ASAP
Thanks in advanced

Regards
D.V. pawar
Dadaso is offline   Reply With Quote
Old 08-17-2012, 01:40 PM   PM User | #3
low tech
Regular Coder

 
low tech's Avatar
 
Join Date: Dec 2009
Posts: 740
Thanks: 149
Thanked 67 Times in 67 Posts
low tech is on a distinguished road
#SACoder

Your code worked for me.

Code:
<div id="demo"></div>
<form name="signoutForm">
<select name="destination" onchange="dest(document.signoutForm.destination.options[document.signoutForm.destination.selectedIndex].value);">
<option value="">Choose</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</form>
<script type="text/javascript">
function dest(destination){
	if(destination == 0){document.getElementById("demo").innerHTML="<input type=\"text\" name=\"dest\" />";
	}else {
		document.getElementById("demo").innerHTML="";
	}
}
</script>
__________________
Ask not what can I do for myself, but what can I do for others

"The greatest revenge is to accomplish what others say you cannot do."
~ Unknown
low tech is offline   Reply With Quote
Reply

Bookmarks

Tags
forms, functions, innerhtml, onchange

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:14 PM.


Advertisement
Log in to turn off these ads.