A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Simple form question

  1. #1
    Senior Member
    Join Date
    Jun 2002
    Posts
    400

    Simple form question

    I have a two drop down menus where you can select two different variables, type of fruit and a utensil. I would then like to take those variables and add them to a string for use as an URL. Here's where I am so far...

    PHP Code:
    <form id="form1" name="form1" action="" method="get">
      <
    strong>Select a fruit:<br /></strong
      <
    select name="fruitSelection" class="fruit_dd">
        <
    option value="">Select...</option>
        <
    option value="apple">Apple</option>
        <
    option value="banana">Banana</option>
        <
    option value="orange">Orange</option>
      </
    select>
      <
    select name="utensilSelection" class="utensil_dd">
        <
    option value="">Select...</option>
        <
    option value="fork">Fork</option>
        <
    option value="spoon">Spoon</option>
      </
    select>
      <
    input name="Button" type="submit" value="Submit" onClick="submitSelections()"/>
    </
    form>

    <
    script type="text/javascript">
    function 
    submitSelections() {
      var 
    newURL="http://www.sampleURL.com/index.html"
      
    //How do I add the fruit and utensil to that URL?

    Any help would be greatly appreciated!

  2. #2
    Senior Member
    Join Date
    Aug 2009
    Location
    Scotland & England
    Posts
    117
    Do you need to use JavaScript for a reason? If you do then sorry for this daft reply


    <form id="form1" name="form1" action="http://www.sampleURL.com/index.html" method="get">
    <strong>Select a fruit:<br /></strong>
    <select name="fruitSelection" class="fruit_dd">
    <option value="">Select...</option>
    <option value="apple">Apple</option>
    <option value="banana">Banana</option>
    <option value="orange">Orange</option>
    </select>
    <select name="utensilSelection" class="utensil_dd">
    <option value="">Select...</option>
    <option value="fork">Fork</option>
    <option value="spoon">Spoon</option>
    </select>
    <input name="Button" type="submit" value="Submit"/>
    </form>

    Would be how to do it with just plain simple HTML...

  3. #3
    Senior Member
    Join Date
    Aug 2009
    Location
    Scotland & England
    Posts
    117
    If you do need to use JavaScipt then the easiest way would be:

    PHP Code:
    <script type="text/javascript">
    function 
    submitSelections() {
    var 
    newURL="http://www.sampleURL.com/index.html" 
    newURL newURL "?fruitSelection="document.form1.fruitSelection.value +"&utensilSelection="document.form1.utensilSelection.value
    alert 
    newURL );

    </
    script>

    <
    form id="form1" name="form1" action="" method="get">
      <
    strong>Select a fruit:<br /></strong>
      <
    select name="fruitSelection" class="fruit_dd">
        <
    option value="">Select...</option>
        <
    option value="apple">Apple</option>
        <
    option value="banana">Banana</option>
        <
    option value="orange">Orange</option>
      </
    select>
      <
    select name="utensilSelection" class="utensil_dd">
        <
    option value="">Select...</option>
        <
    option value="fork">Fork</option>
        <
    option value="spoon">Spoon</option>
      </
    select>
      <
    input name="Button" type="submit" value="Submit" onClick="submitSelections()"/>
    </
    form

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center