SennNathan Posted December 6, 2014 Share Posted December 6, 2014 I need to figure out how to give this input a name so when i submit it i can get the data from it. <!doctype html> <html> <head> <meta charset="utf-8"> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" type="text/css" rel="stylesheet"/> <style> input{font-size:1.3em;} #log{position: absolute; top: 10px; right: 10px;} span{color:blue; text-decoration: underline; cursor: pointer;} </style> </head> <body> <div id="inputs"></div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" type="text/javascript"></script> <script src="jquery.googleSuggest.js" type="text/javascript"></script> <script> $.each("web".split(" "), function(i, v){ var div = $("<div>").appendTo("#inputs") , input = $("<input>").appendTo(div) , span = $("<label>").text(v).appendTo(div); input.googleSuggest({ service: v }); }); </script> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/ Share on other sites More sharing options...
Alex_ Posted December 6, 2014 Share Posted December 6, 2014 Not entirely sure what you meant, but can't you just swap this line input = $("<input>").appendTo(div) with something like input = $("<input name='whatevername'>").appendTo(div) ? Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498771 Share on other sites More sharing options...
SennNathan Posted December 6, 2014 Author Share Posted December 6, 2014 This is what i have now but its still not working <form name="SearchForm" method="get" action="index.php"> <script> $.each("web".split(" "), function(i, v){ var div = $("<div>").appendTo("#inputs") , input = $("<input name='whatevername'>").appendTo(div) , span = $("<label>").text(v).appendTo(div); input.googleSuggest({ service: v }); }); </script> <input type="image" src="search.png" style="height:25px; width:25px"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498772 Share on other sites More sharing options...
Alex_ Posted December 6, 2014 Share Posted December 6, 2014 This is what i have now but its still not working <form name="SearchForm" method="get" action="index.php"> <script> $.each("web".split(" "), function(i, v){ var div = $("<div>").appendTo("#inputs") , input = $("<input name='whatevername'>").appendTo(div) , span = $("<label>").text(v).appendTo(div); input.googleSuggest({ service: v }); }); </script> <input type="image" src="search.png" style="height:25px; width:25px"> </form> Doesn't look like you're adding the input fields to the form? If you are, print the output of $_GET in your php script. It won't be in $_POST considering you're using GET as the form method. Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498774 Share on other sites More sharing options...
SennNathan Posted December 6, 2014 Author Share Posted December 6, 2014 Thats not working here is the link to where i have this http://yousearch.mobi/goog/ 1 Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498775 Share on other sites More sharing options...
Alex_ Posted December 6, 2014 Share Posted December 6, 2014 Thats not working here is the link to where i have this http://yousearch.mobi/goog/ Don't understand what you're trying to achieve. There's an autocomplete on the input field, I get that. But you're not even adding the input fields to the <form> that you wanted to submit. So the data from the input fields will never reach whatever script the form is linked to. Not sure where you're trying to submit either, since there's no submit button. Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498786 Share on other sites More sharing options...
Solution hansford Posted December 6, 2014 Solution Share Posted December 6, 2014 Build up your form inputs in your loop, but at the end, you need to appendTo('form'). Use Firebug or Chrome and then see if they are getting attached as expected. You don't appear to be attaching anything to the actual form. Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498788 Share on other sites More sharing options...
SennNathan Posted December 6, 2014 Author Share Posted December 6, 2014 Im trying to summit whats in the text box to my index.php Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498790 Share on other sites More sharing options...
SennNathan Posted December 6, 2014 Author Share Posted December 6, 2014 This worked for what i needed $.each("web".split(" "), function(i, v){ var div = $("<div>").appendTo("#inputs") , input = $("<input name='keyword'>").appendTo(div) , input = input.appendTo('form') , span = $("<label>").text(v).appendTo(div); input.googleSuggest({ service: v }); }); Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498792 Share on other sites More sharing options...
Barand Posted December 6, 2014 Share Posted December 6, 2014 ..., since there's no submit button. Alex, There is <input type='image'> which will submit the form when clicked, and also pass the x.y coordinates of where the image was clicked Quote Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498793 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.