SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Pass variables, in post form or Get form???

    I have this form below, as selection to set a locaiton for user. However, when I click on the <li>, it post the form to the correct path, but does not take the value="name". what am I missing here, why is not taking the varibale "name". I'm I going down the right street.

    Code:
    
    <form action='index.php' name="submitLocation" >
     <input type="hidden" name="option" value="commuinity" />
     <input type="hidden" name='controller' value="deal" />
    <input type="hidden" name='locationName' value="<?php echo $_POST["name"];?>" />
     <input type="hidden" name="task" value="dealSetLocationCookie" />
    
    <div id="city-option ">
    <img src="templates/deals/images/city_options.png" border="0" class="menu_class" />
    <ul class="city_menu">
    		<li><a onclick="document.submitLocation.submit('atlanta');" title="atlanta" name="atlanta">atlanta</a></li>
    		<li><a onclick="document.submitLocation.submit('chicago');" title="Chicago" name="Chicago">Chicago</a></li>
    		<li><a onclick="document.submitLocation.submit('dallas');" title="Dallas" name="Dallas">Dallas</a></li>
    
    </ul>
    </div>
    
    </form>

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    you have not defined a "method" attribute for your form tag.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,494
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    You mean the hidden form field locationName? The value for that form variable comes from $_POST['name']. Are you sure that it exists and has a value? Take a look at the html code in your browser. What value does that field have?

  4. #4
    SitePoint Wizard bronze trophy Immerse's Avatar
    Join Date
    Mar 2006
    Location
    Netherlands
    Posts
    1,661
    Mentioned
    7 Post(s)
    Tagged
    1 Thread(s)
    The location you have stored in the title tags of your <a> tags. Those aren't submitted when you submit the form.
    Also, passing the name of the location as a parameter to the submit() function on the form doesn't do anything either.

    Any reason why you're not using a <select> for the location?

  5. #5
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    I am trying to get the value added to location echo $name.

    I am using <ul><li> instead of select, for jquery styling I added for cool dropdown.
    Just need to send the value with click on the <a href> for each list item.

    Help if you can.

  6. #6
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I am trying to pass it as in this form is setup, But I al using jquery <ul><li> styling that allows me to make dropdown look and work with jQuery. Do not want to look the effect.
    Just want the onClick event to pass the variable = name(ex.atlanta, dallas) to the form and that's it.

    I can get the form to submit currently when I click on each List item, but it does not carry of load the vairable name with form as it post.

    <input type="hidden" name='locationName' value="<?php echo $_POST["name"];?>" /> Ho do I get the variable to be passed along when form is submitted with correct variable or (city) loading in post as "name"?

  7. #7
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    This sounds like a jQuery question to me.

    If you have a form element such as this : (note it needs an id and a name for JS interaction IIRC)

    <input type="hidden" name='locationName' id='locationName' value="" />

    Then you can tell jQuery to capture the ul/li/a onclick event, assign it to the form element whose id is 'locationName' then submit the form.

  8. #8
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    This sounds like a jQuery question to me.

    If you have a form element such as this : (note it needs an id and a name for JS interaction IIRC)

    <input type="hidden" name='locationName' id='locationName' value="" />

    Then you can tell jQuery to capture the ul/li/a onclick event, assign it to the form element whose id is 'locationName' then submit the form.
    Thank you all for your direction ans support, I have been a member here for some years, I must say. Guys, don't always give you direct assistance.
    But when you get help on these forums. I tell you You get the bessssstessssstsssssssssssssssssssss guidance anyone can ask for.
    Liek getting advice from small-geek god childs.

    Respect to everyone who supports this forum, big up lon gtime. Rah Rah Rah


Bookmarks

Posting Permissions

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