TinyBox inout

Hi hiero,
1. I want to enter the content to the input-box (in TinyBox).
I created a NewFilter
<input  style="width: 200px;" id="NewFilter"  value="">
I see that it creates: tinycontent
So I tried
tinycontent.NewFilter.value="123";
or
document.body.tinycontent.NewFilter.value="123";
but in both cases it doesn't work (it shows an error).

VapiSoftAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

StealthyDevCommented:
Try the below code:


document.getElementById("NewFilter").value="123";

Open in new window

Om PrakashCommented:
<script>
      function Set()
      {
       document.form1.NewFilter.value="123";
      }

</script>

<form method=post name="form1">
<input  style="width: 200px;" id="NewFilter"  value=""/><br>
<input type=button value="dfdsasff" onClick="Set()"; name=test />
</form>

If you want restrict user to enter only 3 digits use this
<input  style="width: 200px;" id="NewFilter2" maxlength="3"  value=""/>
VapiSoftAuthor Commented:
You are right, but I can't  make it work.
I tried to put it under the command Tiny.box.show but it fails (because it takes time to load and it is not ready). It does work if I put it in function that I call from the loaded function.
How can I add an onload function to the HTML (see the attached HTML).
<div id="testdiv">
<h2>
<b>Add Filter-Name</b>
</h2>
<p>
This filter-name belongs to other subjects that are listed in the right list.<br><br>

<a href="javascript:copy_filter()"><b>Copy</b></a><br> 
&nbsp;&nbsp;&nbsp;Copy this filter with all its filter-values (that are listed in the right list),<br>
&nbsp;&nbsp;&nbsp;To the current selected subject (selected in the top-righ list).<br><br>

<a href="javascript:add_new_filter()"><b>New</b></a><br> 
&nbsp;&nbsp;&nbsp;Add this as a new Filter-Name and then create new Filter-Values for it.<br>
<input  style="width: 200px;" id="NewFilter"  value=""><br><br>
<br>

<a href="javascript:javascript:TINY.box.hide()"><b>Cancel</b></a>
</p>
</div>

Open in new window

Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

StealthyDevCommented:
Assuming you are using JQuery, use the below code:

$(document).ready(function(){
    // put your code here
});

Open in new window

VapiSoftAuthor Commented:
I did the following:
$(document).ready(onLoadAddFilterName()
{
 document.getElementById("NewFilter").value="123";      
});
and I placed it in the beginning of the HTML (see the HTML above).
What happened is that I see this line ($(document).ready(onLoadAddFilterName() { document.getElementById("NewFilter").value="123"; });
in the top of the HTML (as if it is a plain text).
If add <script> before and </script> after, then it doesn't show the line but does not put "123" in the input-box.
StealthyDevCommented:
Hi dear. Can you please send both your main HTML page and AJAX page?

You can remove unnecessary contents (if any).

Thanks
VapiSoftAuthor Commented:
Hi senthurpandian,
I posted the HTML page (in the question above).
The ajax code is the TinyBox ajax.js
I don't have anything else.
StealthyDevCommented:
Hi, if you are using tinybox.js

add your code in the below location:



psh:function(c,w,h,a){
			if(a){
				if(!w||!h){
					var x=p.style.width, y=p.style.height; b.innerHTML=c;
					p.style.width=w?w+'px':''; p.style.height=h?h+'px':'';
					b.style.display='';
					w=parseInt(b.offsetWidth); h=parseInt(b.offsetHeight);
					b.style.display='none'; p.style.width=x; p.style.height=y;
				}else{
					b.innerHTML=c;
					//if() // some condition, if you are using the same function in may places.
					document.getElementById("NewFilter").value="123";//custom code
				}
				this.size(p,w,h)
			}else{
				p.style.backgroundImage='none'
			}
		}

Open in new window

Sarika30Commented:
Try calling the function on body load:
<body onload="MyFunction()">
StealthyDevCommented:
Hi author, are you using tinybox.js ?
VapiSoftAuthor Commented:
To senthurpandian.
I am using TinyBox. I add it there and it did not do the job (the input-box is still empty).
It also not a good place. I need to put it in the HTML because I have many HTMLs that I need to do it.
To Sarika30.
Where do I put his code.
I reied in the beginning of the HTML and it did not do the job (it did not get to MyFunction).
StealthyDevCommented:
Ok, i suggest you go with the logic attached.

I think you need to set isMyPageLoaded flag in your code before calling show method.
Then, use

isMyPageLoaded = false;
//TINY.box.show
while(!isMyPageLoaded){}
document.getElementById("NewFilter").value="123";
//

Regards.

psh:function(c,w,h,a){
if(a){
	if(!w||!h){
		var x=p.style.width, y=p.style.height; b.innerHTML=c;
		p.style.width=w?w+'px':''; p.style.height=h?h+'px':'';
		b.style.display='';
		w=parseInt(b.offsetWidth); h=parseInt(b.offsetHeight);
		b.style.display='none'; p.style.width=x; p.style.height=y;
	}else{
		b.innerHTML=c;
		isMyPageLoaded = true;
	}
	this.size(p,w,h)
}else{
	p.style.backgroundImage='none'
}
}

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sarika30Commented:
call the function when your page is being loaded. i assume that an html code is loaded. So call this function inside the <body> tag of your page.
StealthyDevCommented:
Dear Sarika30,

It will not work, because he is using a custom JavaScript, using which he is loading all the HTML content into a variable and substituting into a div element.

Regards.
Sarika30Commented:
try putting the code in the show() function of the tinybox.js
After it has appended things to the document.body
VapiSoftAuthor Commented:
I used this solution, but instead of while that causes an error, I use setTimeout to another function.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.