It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Textbox value link to Iframe

Textbox value link to Iframe

Postby daipayan on Fri Oct 08, 2010 5:34 am

Hello Developers,

I am a newbie in javascript.
Let me explain my query.
I have 5 web-pages that will be shown in an iframe in a html web-page. Now each page is equal to a value that will be shown in readonly textbox.

E.g. If value in textbox shown "1", then 1.html will be shown in the iframe i.e. embedded in the html web-page. Again, if value in textbox shown "2", then 2.html will be shown in the iframe i.e. embedded in the html web-page.

Hope I can explain my query properly.

Please help me, as I am in great need of this query.. :roll:

Thanks & Regards,
Daipayan
daipayan
 
Posts: 3
Joined: Fri Oct 08, 2010 5:31 am

Re: Textbox value link to Iframe

Postby HotNoob on Fri Oct 08, 2010 8:39 pm

something like this
Code: Select all
<script>
function changePage(page)
    {
        index = page.lastIndexOf(".");
        document.getElementById("page").value = page.substring(0,index);
        document.getElementById("mainFrame").src = page;   
    }

</script>
<a onclick="changePage('1.htm');">testpage</a>
<input id="page" type="textbox" />
<iframe id="mainFrame" width="100% height=600"></iframe>

i think that's what you were trying to do.
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am

Re: Textbox value link to Iframe

Postby daipayan on Sat Oct 09, 2010 11:08 am

Hello HotNoob,

Thanks for replying.
But I want the exact thing opposite thing. Textbox value should linked with Iframe. If textbox value come as 1, then in iframe, 1.html should show; if textbox value changed to 2, then 2.html and so on.

Hope you understand my query.

Daipayan
daipayan
 
Posts: 3
Joined: Fri Oct 08, 2010 5:31 am

Re: Textbox value link to Iframe

Postby HotNoob on Sat Oct 09, 2010 5:30 pm

whoops, sorry my bad,
Code: Select all
<script>
function changePage(object)
    {
        document.getElementById("mainFrame").src = object.value + ".htm";
    }

</script>
<a onclick="changePage('1.htm');">testpage</a>
<input id="page" type="textbox" onkeydown="if (event.keyCode == 13){changePage(this)}"/>
<iframe id="mainFrame" width="100% height=600"></iframe>

that should do it.
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am

Re: Textbox value link to Iframe

Postby daipayan on Mon Oct 11, 2010 7:32 am

Hi HotNoob,

Can't
Code: Select all
<a onclick="changePage('1.htm');">testpage</a>
be removed and textbox can be directly linked with iframe??

Daipayan
daipayan
 
Posts: 3
Joined: Fri Oct 08, 2010 5:31 am

Re: Textbox value link to Iframe

Postby HotNoob on Mon Oct 11, 2010 10:16 pm

whoops srry, forgot to remove that line, was in a rush.
HotNoob
100+ Club
 
Posts: 169
Joined: Sun May 02, 2010 1:38 am


Who is online

Users browsing this forum: No registered users and 4 guests

cron