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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danjapro
Forum Commoner
Posts: 72
Joined: Mon Sep 27, 2004 10:56 am

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

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

User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

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

Post 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.
mikeashfield
Forum Contributor
Posts: 159
Joined: Sat Oct 22, 2011 10:50 am

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

Post 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.
danjapro
Forum Commoner
Posts: 72
Joined: Mon Sep 27, 2004 10:56 am

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

Post 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"?
icesolid
Forum Regular
Posts: 502
Joined: Mon May 06, 2002 9:36 pm
Location: Buffalo, NY

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

Post 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?
danjapro
Forum Commoner
Posts: 72
Joined: Mon Sep 27, 2004 10:56 am

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

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