Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   JavaScript and Client-Side Browser Scripting (http://www.programmingforums.org/forum23.html)
-   -   Frame Location? (http://www.programmingforums.org/showthread.php?t=606)

Pizentios Sep 20th, 2004 11:34 AM

Hey,

I am currently trying to get a iframe to move location when a Search button is clicked on. Here's some code to help me explain:

:

<html>
 <head>
  <script langugae="javascript">
  function search() {
    window.frames["cuslist"].location = "cuslist.php?action=search&sstring=" + document.forms["Search"].searchb.value;
  }
  </script>
</head>
Bla, bla, bla.....


searchb is the textbox that the user types in their search string.

Anyways, this function doesn't work, when the button is clicked. Here's the code for the button.

:

<input type="submit" value="Search" onclick="search()">

Does anything look out of place to you guys? I am not very good at javascript, since i havn't used it alot in the last three years. I have tryed reading a bit on the net, however i don't really have the time to really sit down and read. Thanks for your help in advance.

Ooble Sep 20th, 2004 3:38 PM

Why have you got a string in the location? I'm not sure exactly how that one works (I've never used it), but doesn't it just take a number?

So, what exactly are you trying to do?

Berto Sep 21st, 2004 2:52 AM

the only way i could think of doing it is having a second frame in the location where you want it to move to then using window.open command in javascript to open it up. And also hide the other frame.

Pizentios Sep 21st, 2004 8:45 AM

I am pretty sure that you can change the location of an iframe , and i think i have done it before....i just can't remember how. ;-)

Quote:


Why have you got a string in the location? I'm not sure exactly how that one works (I've never used it), but doesn't it just take a number?

Simple. You can use strings in your location, it's not just for numbers. I like strings better because i don't get them mixed up like i would with numbers. For example, if you had 4 vars in a c++ program are you going to name them 1,2,3,4? I doubt it. For me, this is the way things make sense.


I'll post back today when i find the answer.

Ooble Sep 21st, 2004 11:29 AM

Oh, I see... it's like a goto thingy. Fair enough.

Pizentios Sep 23rd, 2004 9:17 AM

Yeah, then in the page that gets called, i have a switch running which code i want.

Berto Sep 23rd, 2004 9:40 AM

i would use a server side scripting and just chuck something in teh url you are sending

:


if (req.getParameter("a").equals("1)){
show frame here
}else{
show frame there
}



URL: http://location.com?a=1 and http://location.com?a=12


thats java btw :)

would give you 2 different pages, i could show you the code to do it in php or asp .net as well and the rest of them could show you in the other languages they no.

Pizentios Sep 23rd, 2004 10:31 AM

What i am trying to do, is when the user enters somthing into the search box and clicks the "Search" button a frame on the page will change location and display the search results. For the search code (it's in php) to work, i need to have a url somthing like this: cuslist.php?action=search&sstring=K. cuslist.php is a php file that handles all of the customer search functions as well as displaying any infomation about the customer. So when the cuslit.php file is called i have a switch that looks at the action part of the query string, and executes some code according to what the action part of the string is. The second part of of the query string is the actual search string that get's checked against the db. Anyways, the only problem that i have with this stuff is the java redirect side of it. I don't think that i can do server side scripting because the user must type somthing in before we can redirect it , otherwise i would use php to do it. I am testing in firefox. I have found scripts on websites that do what i want to do, but when i implement them into my page they don't work, do you guys think it could be firefox causing the problem?

Berto Sep 23rd, 2004 10:43 AM

if i am correct in thinking you want to load a page that says searching then that page redirects to a final page?

well with javascript you can use,

:

*

 <script language=\"JavaScript\">
<!--hide

function newwindow(type)
{
        if (type == \"pic\" && document.addnew.picture.value != 0){
 *window.open('Preview?typ=pic&img=' + document.addnew.picture.value,'jav','width=600,height=600,resizable=yes');
        }else if(type == \"dia\" && document.addnew.diagram.value != 0){
 *window.open('Preview?typ=dia&img=' + document.addnew.diagram.value,'jav','width=600,height=600,resizable=yes');
        }else if(type == \"vid\" && document.addnew.video.value != 0){
 *window.open('Preview?typ=vid&img=' + document.addnew.video.value,'jav','width=600,height=600,resizable=yes');
}
}
//-->
</SCRIPT>
------------------------------------------------------------------------

<a href=\"javascript:newwindow('pic')\">Preview</a><--- to call the javascript

name your iframe you want load it in the all is good, just takes the value from teh txt box

or use a dynamic redirect in PHP, just check the request string from teh url and if it is say for instace

you find action=search then use the php redirect?

http://www.mozilla.org/docs/dom/domr...dow_ref76.html <--- window.open documentation.


this is about the 20th edit of this post but...

can i see the code you are trying to impliment?

Infinite Recursion Sep 23rd, 2004 11:26 AM

Quote:

think it could be firefox causing the problem?

In my experience with web dev, some things that work in IE don't work in Firefox, and vice versa... Try testing with an alternate browser just to rule out a browser conflict.


All times are GMT -5. The time now is 11:03 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC