0

I have 2 forms, 1st form is to submit an input value to the next page, and on the next page there's the 2nd form which is a search map function.

the 1st form is displayed on the homepage

<form role="search-map" method="" id="search-map" action="/find">
    <h4>Where To Buy</h4>
    <input type="text" class="form-control" id="addressInput" name="addressInput" placeholder="Your Suburb or Postcode">
    <button type="submit" class="btn btn-vc btn-default btn-lg" id="search-address-btn">Find</button>
</form>

the 2nd form is on another page which is /find that has a map search plugin

<form onsubmit="cslmap.searchLocations(); return false;" id="searchForm" action="">
  <input type="text" id="addressInput" name="addressInput" placeholder="Your Suburb" size="50" value="where-i-want-value-to-be-pass">
  <input type="submit" class="slp_ui_button" value="Find" id="addressSubmit">
</form>

any ideas how can i pass the value from the 1st form "addressInput" to the 2nd form? and the run the search on the 2nd form? here's the 2nd form btw

i tried searching here but what i need seems to be more complex that what i have found

or maybe how can i get the 2nd page to get the value from the url (?addressInput=North+Bega%2C+NSW%2C+2550) into the 2nd form input "addressInput" and run the submit button function when the page loads?

thanks in advance guys

3
  • what value are you trying to pass to the second form? I guess that would be s but I can't see where would you want to use it on the second form. ¿A hidden input, maybe? Commented Jun 9, 2014 at 21:44
  • yes i'm trying to pass the value of input "s" from the 1st form to the 2nd form input "addressInput" Commented Jun 10, 2014 at 8:36
  • i updated my question so it would be easier to understand sorry for the missing parts earlier Commented Jun 10, 2014 at 10:16

1 Answer 1

0

I'm assuming you want to get the value from s to the second form.

replace where-i-want-value-to-be-pass with <?php echo $_REQUEST['addressInput']; ?>

<form onsubmit="cslmap.searchLocations(); return false;" id="searchForm" action="">
  <input type="text" id="addressInput" name="addressInput" placeholder="Your Suburb" size="50" value="<?php echo $_REQUEST['addressInput']; ?>">
  <input type="submit" class="slp_ui_button" value="Find" id="addressSubmit">
</form>
Sign up to request clarification or add additional context in comments.

2 Comments

thanks ric, however what im trying to get is do a auto search on the page by getting the value from the url example: chemtools.circlebc.org.au/find/… and then the value from the url would be assign on the 2nd form input "addressInput" and then auto submit or run the search.. sorry for my bad english
I just updated the code with the addressInput variable. You are still passing addressInput from one page to the other, you can do it with the code I wrote.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.