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> 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) ? 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> 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 On 12/6/2014 at 4:39 PM, SennNathan said: 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. 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/ 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 On 12/6/2014 at 5:05 PM, SennNathan said: 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. Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498786 Share on other sites More sharing options...
hansford Posted December 6, 2014 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. 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 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 }); }); 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 On 12/6/2014 at 6:12 PM, Alex_ said: ..., 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 Link to comment https://forums.phpfreaks.com/topic/292932-php-forum-name-help/#findComment-1498793 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.