Click to See Complete Forum and Search --> : On Click Event


txmail
09-06-2003, 02:27 AM
Hello All,

This is my first time on this forum, while it is filled with add's it has allot to offer. I have a question for you JavaScripting gurus out there. (I am a ASP coder, and try to stay away from Java Script, but it seems that in this case it is the easiest way, or so I thought).

I have a page, with three fields, and IFRAME and three links. I know that this answer is going to have to do with the onClick event but I cannot seem to find it anywhere.

I need to have the IFRAME on the page change once a link is clicked on the page, but on top of that I also need the link to contain a portion of the field. For Instance.

If the field has 3234 in it, I need the IFRAM to navigate to a url such as somepage.asp?token=3234. Any suggestions. I am sure this will be cake for you guys. If anyone needs help with ASP or MySQL let me know. I will start to lurk the forums now. Thanks.

Mr J
09-06-2003, 07:06 AM
Please see the zip file to see if I fully understood your question.

I created three text field and three links.

When a link is clicked the appropriate text field value is used as a file name and loads that page

Fang
09-06-2003, 07:24 AM
Or this:

<a href="nojavascript.html" onclick="iframename.location.href='somepage.asp?token='+parseInt(document.formname.elementname.value); return false;">load frame</a>

txmail
09-06-2003, 11:18 PM
I have tried both of theese examples but cannot get either to work. I get a script error "unknown object" with the first example (with the zip file). I am not sure if I am supposed to put the example with the zip file in the head section of the page or just anywhere in the page. I tried to make some changes to the script as I need the iframe to navigate to a page such as http://www.somewhere.cf?value=VALUE where VALUE would equal the value in the input box. Let me know what I am doing wrong, I think I am close but not quite there yet.

My source code is below:

<script>
function loadme(n){

switch(n){
case 1:
document.fdisplay.location.href=document.main.fd1."psmwin.cfm?deal="+value;
break;

case 2:
var fd2="psmwin.cfm?deal="+document.main.fd2.value;
document.fdisplay.location.href=fd2;
break;

case 3:
document.fdisplay.location.href=document.main.fd3."psmwin.cfm?deal="+value;
break;

default :
alert("oops")
}
}
</script>

You can see on case two I tried to modify it to have the value of the URL in it, but it does not seem to work either. Here is the A HREF tag:

<a href="#null" onclick="loadme(2)">View Fast Deal</a>

Thanks for all of your help JS gurus.

Fang
09-07-2003, 12:27 AM
case 1 and 3 were causing the error.
This should do it:

switch(n){
case 1:
fdisplay.location.href="psmwin.cfm?deal="+value;
break;

case 2:
var fd2="psmwin.cfm?deal="+document.main.fd2.value;
fdisplay.location.href=fd2;
break;

Mr J
09-07-2003, 03:01 AM
As Fang has pointed out, you got it right for case 2 but messed up on case 1 & 3

Place the script in the HEAD section

;)

txmail
09-07-2003, 02:02 PM
Awesome, it works, thanks everyone for your help. I have never gotten into a forum but I am having a great time on this one with helping everyone, thanks again!