1

Using JavaScript I managed to add a variable to a page and used $_GET on the new page to use the variable to perform queries. This first implementation worked fine as I was only using one variable. However I need to use two variables now and I'm running into some problems while doing it. If I combine both variables in the first page like shown below, the values are mixed up where my db value goes to my table id.

 window.location.assign("test.php?db=&tbl=" + yourDB);

I tried putting both IDs only in my new page and using reload as my DB value would already have been passed. Using

 window.location.reload("test.php?db=&tbl=" + yourTbl);

But this doesnt work either.

How can I get the url to have both my DB and table in the correct format? Like

test.php?db=test&tbl=customer 

EDIT yourDB variable is passed from a select form option from a different page which in turn opens the new page where the yourTbl variable exists.I can't therefore call yourDb

1 Answer 1

3
window.location = 'test.php?db=' + yourDB + '&tbl=' + yourTbl ;

'OP is asking: yourDB since this variable stores the values of select options from a different page.Any ideas'

My answer is 'Get value from selection menu list in the another page, and save this value into local storage or session storage.'

Something like this,

// save your db
window.sessionStorage.setItem("db", yourDB)
// get your db
var obj = window.sessionStorage.getItem("db");
Sign up to request clarification or add additional context in comments.

2 Comments

I think that those variables need to be switched (db=' + yourDB) :)
Thanks for your response and the example.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.