Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request in Javascript

Status
Not open for further replies.

zishan876

Programmer
Mar 19, 2007
61
US
hi all:
I have a url with a variable: (page1.html)
var ul= "/servlet/servlet.Integration?lid=01N500000004xKp&ic=1&posid=" + recordIds;

window.open(ul,"message_box","width=200,height=200,resizable=no,scrollbars=no" )
That works fine to pop it open but ...

The recordIds is the var... it is opening up a report(page2.html) which I need the variable to be passed in... The report is written in javascript...
Does anyone know how to place the recordIds into my SQL Statement on Page2.html???

Thanks
 
Access the location.search and then use string manipulation to gain access to the posid key (and associated value).

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
ok So I did so far:

var URLLength= window.location.href.length;
var URLString = window.location.href;
var startingPos = URLString.lastIndexOf("posid");

var idName = URLString.substring(startingPos+6,URLLength);
alert(idName);
var strSQL="SELECT Id, CaseNumber, Status, Reason, Subject, Description FROM CASE where Id in('" + idName + "')";
alert(strSQL);

This works except when I have two or more IdName.. for example when idName = 23,34,45
My sql statement comes in as where Id in ('23,34,45') when it should be
where Id in ('23','34','45')

Anyone know how to do that given scenario?
Thanks
 
so I tried
var idName = URLString.substring(startingPos+6,URLLength);
var myNewString = idName.replace("," , "','");

it works if you have two numbers like
'24,35' my new value would '24','35'
if i have
'24,35,46'
then
it would just do the first two
'24','35,46'
WHY??
Please help..
 
Excellent news [smile]

Care to share (so that the next person searching for a similar solution can read and learn from your experience)? It's kinda what we do here.

Cheers,
Jeff

[tt]Jeff's Blog [!]@[/!] CodeRambler
[/tt]

Make sure your web page and css validates properly against the doctype you have chosen - before you attempt to debug a problem!

FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top