hi i have a script that is in php and this is how the code is like $contents .= " //html code here the code here "; PHP: and this is one of my js function function domain_form_submit() { document.theform.submit(); } Code (markup): and i want to add this form however is facing a problem because this js function is not loading and i get a php error <form method="post" action="root.php" name="theform"> <input type="text" id="metanav-search-field" value="enter domain name" onclick="javascript:this.value='';" name="url"> <button id="domain_search_btn" class="oBtnPrimary oBtnInline" onclick="domain_form_submit();">Search</button> </form> Code (markup): please i need help on how i can solve this
hey problem here is that i have to put the form in a php variable as this <?php $content .=" <form method=\"post\" action=\"root.php\" name=\"theform"\> <input type=\"text"\ id=\"metanav-search-field\" value=\"enter domain name\" onclick=\"javascript:this.value=\'';" name=\"url\"> <button id=\"domain_search_btn\" class=\"oBtnPrimary oBtnInline\" onclick=\"domain_form_submit();\">Search</button> </form>"; Code (markup): and im get errors since the script templating is that every code has to be inside $content .=" "; so the problem is how can target the class instead of adding the js in the form. I'm not that experienced in coding so i need help
There are a few different ways to get the form into the variable but this might make it a bit easier <?php $content .=" <form method='post' action='root.php' name='theform'> <input type='text' id='metanav-search-field' value='enter domain name' onclick='javascript:this.value=';' name='url'> <button id='domain_search_btn' class='oBtnPrimary oBtnInline' onclick='domain_form_submit();'>Search</button> </form>"; HTML: but something else I do when building up a complex string like this is to take a building blocks approach like this: <?php $blocks = []; $blocks[] = "<form method='post' action='root.php' name='theform'>"; $blocks[] = "<input type='text' id='metanav-search-field' value='enter domain name' onclick='javascript:this.value=';' name='url'>"; $blocks[] = "<button id='domain_search_btn' class='oBtnPrimary oBtnInline' onclick='domain_form_submit();'>Search</button>"; $blocks[] = "</form>"; $content .= implode($blocks); HTML:
Hey thanks, I was still getting PHP error because the script coding style is old but i used this and it worked since it getting the form to query info from the other site which is not on my server $content .=" <form method=\"get\" action=\"https://www.example.com/reports.php\" name=\"theform\"> <div class=\"input-group\"> <input type=\"text\" class=\"form-control\" name=\"domain\" placeholder=\"Type domain name..\"> <span class=\"input-group-btn\"><button type=\"submit\" name=\"submit\" class=\"btn btn-primary\">get info</button></span> </div> </form>"; Code (markup): i just got lead of the js