Page 1 of 1

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

Posted: Mon Nov 07, 2011 7:52 am
by danjapro
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: Select all



<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>


Re: Pass variables, in post form or Get form???

Posted: Mon Nov 07, 2011 11:41 am
by manohoo
1. Your form does not have a method (get or post)
2. Submit button is missing too
3. Onclick is on a list item, not a button.
4. "down the right street?" I don't know, maybe a GPS could help.

Re: Pass variables, in post form or Get form???

Posted: Mon Nov 07, 2011 11:46 am
by mikeashfield
Just summarise what you think your code does? Or, let me rephrase that, what you would like it to do. Perhaps one of us could try and help if we knew exactly what you were trying to do.

Re: Pass variables, in post form or Get form???

Posted: Mon Nov 07, 2011 2:52 pm
by danjapro
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"?

Re: Pass variables, in post form or Get form???

Posted: Mon Nov 07, 2011 3:07 pm
by icesolid
Well it seems like you are trying to break the mold of using a form in the middle of using a form. Why not make the whole form ajax and process in the background and this way here you wont need an actual "form", all of these actions will happen in the background?

That's how I would do it, why try and use some ajax when it can all be ajax?

Re: Pass variables, in post form or Get form???

Posted: Mon Nov 07, 2011 11:57 pm
by danjapro
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