0

i have a file main.js where every step pass selected variable to php page, i need pass some variable to another one php page.

this is piece of code of main.js, i tryed to get 'optionsContent' variable and put in a index.php page in a 'div id="rip" with 'document.getElementById("rip").innerHTML = optionsContent;' but tryed to pass this variable with 'href' in new.php page and not work

if( selectedOptions.length == 0 ) {
                    optionsContent = '<li><p style="color:#FF0000">Nessuna Riparazione Selezionata</p></li>';
                } else {
                    selectedOptions.each(function(){

                        optionsContent +='<li><p>RIPARAZIONE '+$(this).find('.searchText1').text()+'</p>'+' - '+'<p style="color:#0012ff">' +$(this).find('.price').text()+'</p></li>';
                        //optionsContent +='<li><p>'+$(this).find('p').text()+'</p></li>';
                        //document.getElementById("new").innerHTML = optionsContent;

                        document.getElementById("rip").innerHTML = optionsContent;





                    });
                }

                self.summary.find('.summary-accessories').children('li').remove().end().append($(optionsContent));
            }
        }); 

index.php page


<div id="rip">** HERE GET 'optionsContent' VAR CORRECTLY **</div>

 <li class="next nav-item">
                    <ul>
                        <li class="visible"><a href="#0">Modello</a></li>
                        <li><a href="#0">Colore</a></li>
                        <li><a href="#0">Riparazione</a></li>
                        <li><a href="#0">Sommario</a></li>
<li class="buy"><a href="/new.php?riparation=<? $rip; ?>">Prenota</a></li>

                    </ul>
                </li>

in new.php page

<?php
$riparation = $_GET['riparation'];
?>
<input name="riparation"><?php echo $riparation; ?></input>

but doesnt work

any help?

1 Answer 1

1

You can use cookies or data storage API for saving data between pages.

index.html:

<?php
// set the cookies:
setcookie("riparation", "myDataFromApp");

// Render the page:
echo "<h1>This works!</h1>"
?>

Another page (jQuery cookie plugin required):

var riparation = $.cookie("riparation"); // riparation = "myDataFromApp"
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Dunaevsky Maxim, but i have no confidence with cookies and API data storage, can u make an 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.