Computing.Net > Forums > Programming > Javascript Menu - Call to PL/SQL

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Javascript Menu - Call to PL/SQL

Reply to Message Icon

Name: Infinite Recursion
Date: March 18, 2004 at 07:23:12 Pacific
OS: win2k
CPU/Ram: 2gb
Comment:

I am trying to navigate to another page while taking a variable from the source page along with me, to use at the destination page.

I am using PL/SQL, my menu is written in Javascript.

With a simple button, I can do what I need to do...

<FORM action=UU.UPP?psU='||temp2||' method="post">
<input type=submit value="temp1" name=temp1>
</FORM>

However, I am replacing the standard buttons with a Javascript menu...

Menu2=new Array("Temp1","UU.UPP?psU='|| temp2 ||'","",0,0,105,"","","","","");

The second element of the array is the call to the stored PL/SQL function. I would like to use the javascript menu system to have the site's navigation uniform with other sections. However, using the menu syntax above... destroys my menu.

My question is, does anyone know how I can call a stored PL/SQL function from within a javascript menu array, or at the very least how can I call the button to execute the code indirectly from within the menu array. I am bombing out on the syntax I believe. Perhaps a ' or " or a set of either/or are misplaced or missing altogether.

Any suggestions?

IR



Sponsored Link
Ads by Google

Response Number 1
Name: SN
Date: March 18, 2004 at 10:10:23 Pacific
Reply:

My guess is that the main javascript function loops 
through an array of the menu arrays, and prints out 
the navigation?  So the info used in the Menu2 array 
is used in forming and positioning a link in the navigation?

Going on several assumptions, here are some guesses:
Menu2=new Array("Temp1","UU.UPP?psU='|| temp2 ||'","",0,0,105,"","","","",""); 


Let's say the meny system js has something like:
print "<A href='"+Menu2[1]+"'>"+Menu2[0]+"</A>";

Then the single quotes in Menu2[1] would mess everything 
up.  If you're passing something via get, you don't 
need the quotes anyway.

A possible hack would be to look at the js code that 
outputs this stuff, and do something like (assuming 
the previous outputting command and that you have a 
form like the one you mentioned, and a function submitForm() 
that submits it)
Menu2[1]="UU.UPP?psU=|| temp2 ||' onclick=submitForm()";

Dirty?  Extremely.  But if you can't modify the menu 
system, you may be stuck with something nasty like 
that.

If you have more info on the menu system, post back 
and maybe I can make a more reasonable guess.

I'm off kayaking for the weekend, so I don't know if 
I'll see this one through.

-SN


0

Response Number 2
Name: Infinite Recursion
Date: March 18, 2004 at 10:44:09 Pacific
Reply:

Hi SN. I am using the Menu Simple Version with the RelativePosition option menu script at the following location:
http://www.burmees.nl/menu/zips/menusimple.zip

You are right on your guess in regards to the menu generation. Currently, I have a javascript function that has the link for the stored procedure...

function go1()
{
top.window.location.href="UU.UPP?psU='|| temp2 ||'";
}

Listed in the menu array as...

Menu2=new Array("Change Passwords","javascript:go1()","",0,0,105,"","","","","");

It gets to the page, but the variable temp2 is blank as if I didn't pass it in. The variable is just a simple string... (ie: D5LLLERT)

The URL is not fully constructed...

https://xxxxxxxxxxxxxxxxxx:1234/subdir/UU.UPP?psU=

where it should be derived to

https://xxxxxxxxxxxxxxxxxx:1234/subdir/UU.UPP?psU=D5LLLERT

I'm fairly sure its a missing ' or ". Just locating it seems to be impossible. lol

Thanks for your time SN.


IR



0

Response Number 3
Name: anonproxy
Date: March 18, 2004 at 11:00:24 Pacific
Reply:

Strings are delimited with double quotation marks - I think this is native to the data type, not just array declarations. So use escape characters. I just tried this in one array element:

///Example

var Menu = new Array();

Menu[0] = "Temp1","UU.UPP?psU='|| temp2 ||'","",0,0,105,"","","","","";

document.write(Menu[0]);

///End

It only printed Temp1. I tried the same thing with a literal array. I then proceeded to cut out all double quotes.

///

Menu[0] = "Temp1,UU.UPP?psU='|| temp2 ||',,0,0,105,,,,,;"

///

That prints out the entire element (without the quotes of course). Now with escape characters:

///

Menu[0] = "\"Temp1\",\"UU.UPP?psU='|| temp2 ||'\",\"\",0,0,105,\"\",\"\",\"\",\"\",\"\"";

///

That returns the entire string, untouched. Remember a backslash \".



0

Response Number 4
Name: SN
Date: March 18, 2004 at 11:29:17 Pacific
Reply:

Sorry if this suggestion is foolish, but:

function go1()
{
top.window.location.href="UU.UPP?psU='|| temp2 ||'";
}

I get the impression that temp2 is a variable, and assuming temp2="hello", you would go to the page
UU.PP?psU='||hello||'

Is this right?

Javascript isn't as neat as PHP and Perl...It doesn't parse double quoted strings...You need to use the Java form of concatenation:

top.window.location.href="UU.UPP?psU='||"+ temp2+" ||'";

This would seem to be the problem, except you said that it gets to the page:
UU.UPP?psU=
so it didn't get anything at all after the = sign...This isn't consistent with my guess. The URL needs to be encoded anyway, so you might try:
top.window.location.href="UU.UPP?psU=%27%7C%7C"+ temp2+" %7C%7C%27";

If you're using Perl, make sure you decode it (cgi101.com has a very nice way). PHP does it for you.

I'm not sure where anonproxy is going...You don't want it all to be in one element, do you? Maybe I've misunderstood from the beginning.

Good Luck
-SN


0

Response Number 5
Name: anonproxy
Date: March 18, 2004 at 12:03:27 Pacific
Reply:

"I'm not sure where anonproxy is going..."

Nowhere in particular, actually. After drinking something, I realized how off topic I was. I usually declare elements explicity so I don't have to count. Regardless, the syntax don't seem to be the problem.

"Javascript isn't as neat as PHP and Perl...It doesn't parse double quoted strings..."

PHP and Perl parse everything, they don't interpolate (evaluate) everything so you have less problems with namespace (remember using a variable creates it automatically). PHP does interpolate double quotes - single quotes are passed as strings. Javascript parses everything and interpolates in most cases.

What is the scope of temp2? Where is it defined?

"it didn't get anything at all after the = sign..."

This is one of those times you wish javascript complained about undefined variables. The variable probably is defined, but it's value hasn't been passed, possibly because it is nested in another part of the scope chain. To find this out, we need to relate where the variable's value is defined in relation to function go1(). Of course, I could just be going off topic again...


0

Related Posts

See More



Response Number 6
Name: Infinite Recursion
Date: March 18, 2004 at 12:54:07 Pacific
Reply:

"I get the impression that temp2 is a variable, and assuming temp2="hello", you would go to the page UU.PP?psU='||hello||' "

This syntax would go to UU.PP?psU=hello if it were to work correctly.

I agree, I would have used PHP for this personally... but this code has been in
use for quite some time, I am just doing some maintainence on legacy code.

SN, Yep, the entire string would need to be in one array so I could just append it to the URL, its probably my fault for not explaining the scenario very well. lol. So its understandable if you say you are lost from the beginning.

The temp2 variable was defined in a remote PL/SQL package and sent in to the local package that I was working with the javascript menu in. I had my doubts that for some reason temp2 never was assigned a value or was hammered with a NULL. After testing, that was not the case.

After wasting away in my own mind, I decided to modify the package to accept a global variable to dynamically construct a string that I appended to the main javascript menu array. That gave me the result that I needed for the redirection to take place.

I appreciate the input guys. Thanks.

IR


PS: SN, at least someone can relax this weekend.. I want to go Kayaking to :( ... I spent last weekend in New Orleans, and this weekend
I am flying out to Chicago on sunday (for a PL/SQL class none the less), not looking forward to that. Enjoy the kayaking trip man. :)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Javascript Menu - Call to PL/SQL

Pl sql www.computing.net/answers/programming/pl-sql/4688.html

PL/SQL variable to Unix shell www.computing.net/answers/programming/plsql-variable-to-unix-shell/17173.html

Javascript menu woes www.computing.net/answers/programming/javascript-menu-woes/8389.html