Home > Back-end >  Passing script variable to the next page
Passing script variable to the next page

Time:08-31

I've got spinning wheel script that I'm trying to use to give away small prizes to visitors when they login to a website. The wheel animation all works great and the script puts the 'result' into a variable and displays that in a modal on the page. You can see it in action here...

https://ezclix.club/wheel2/index.asp

The result value shows up as the third line in the modal, inserted t oa span #displayprice.

 var response = "";
 response  = selectedSegment.winResult;
 $("#displayprice").html(response);

I just need to get that value to the next page, so I can actually 'award' the prize, but so far nothing I've tried seems to work.

I tried setting a cookie but that doesn't make it through.

 setCookie("Prize", response, 1)

I've tried adding a form to the modal, and using jquery to update an input with the result value, but that doesn't want to work either.

$('input[id=passprize]').val(response);
$('input[name=passprize]').val(response);

I've tried adding a whole new form input, but no go there as well.

I don't do much with jquery and my experience is mostly limited to minor edits to existing scripts, but the edits above are all things I've done in the past, so I'm stumped.

Any ideas at all much appreciated!

Here's the full function...

function alertWinResult(selectedSegment) {

jQuery(".spin_pin").rotate(0);
$("#spinWinResult").text(globlefuncgeneral.gameover_text);
$(".power_controls").hide();

var response = "";
response  = selectedSegment.winResult;
$("#displayprice").html(response);

// My variousattempts... 

setCookie("Prize", response, 1)

$('input[id=passprize]').val(response);
$('input[name=passprize]').val(response);

}

CodePudding user response:

You can use url parameter to pass the prize when redirect to next page url/action?prize={response}

CodePudding user response:

enter code here

//Using cookie
setCookie("Variable", response, value)

//using url redirect 
next page url/action?Variable=value

  • Related