1

I need to pass an id to a modal popup.... the modal is then used to fill in a form.

Here is my code for calling the modal...(the echo below is in a loop which should give each a differing data-id

 echo '<a class="sign-up" href="#" data-reveal-id="modal-tournament" data-reveal data-id= "<? echo $tournament_id;?>" >SIGN UP</a>'; 

The tournament_id is then needed to be passed as a hidden field in the form below.

And this is my modal and form

<div id="modal-tournament" class="reveal-modal" data-reveal> <h3>Sign up to Tournament</h3> <p>To sign your team up to take part in this tournament, enter you team name, username and email address and click</p> <p></p> <form enctype="text/plain" method="get" action="#"> <p>Team Name: <input type="text" name="team_name"></p> <p>Username: <input type="text" name="username"></p> <p>Email: <input type="email" name="email"></p> <input type="hidden" name="tournament_id" value="XXXXXXX"> <input type="submit" value="Join"> </form> <a class="close-reveal-modal">&#215;</a> </div> 

Any ideas how I can achieve this.. I am at a bit of a loss...

Thanks

0

1 Answer 1

1

As you mentioned, you are using Modal. Modals are part of DOM. So, you can easily access the hidden field in modal form from the script to set. eg If you are using JQuery, you can set like $('#TournamentId).val('YourIdValue');

One way could be when you click SIGN UP, you can set the tournamentId

Sign up to request clarification or add additional context in comments.

1 Comment

Not sure I understand. I am passing the tournamentID in the modal call by setting the data-id of the modal, I think... I just need to then get this whilst IN my modal and assign it as the value of the hidden field tournament_id.... I don't understand how your answer helps me do that... Sorry for seeming a little dense.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.