php - search into a website and result shows in iframe using javascript -


i have 2 input box , button. if entered url in first text box , entered search text in second text box. need results in iframe. tried screen empty....

here code....

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <?php  header('x-frame-options: goforit'); ?> <head> <script type="text/javascript">   function gsitesearch(curobj) { var domainroot=document.frm.domain.value; var date=document.frm.opt.value; curobj.q.value="site:"+domainroot+" "+curobj.qfront.value+" "+curobj.opt.value } </script> </head> <body> <form action="http://www.google.com/search" id="frm" name="frm" target="myiframe" method="get" onsubmit="gsitesearch(this)"> <center> <h2>search tool kit:</h2><br /> <table cellpadding="10" cellspacing="10"> <tr><td><input name="q" type="hidden" /></td></tr> <tr><td><b>domain name:</b></td><td><input id="domain" type="text" style="width: 180px" /></td></tr> <tr><td><b>search word</b></td><td><input name="qfront" type="text" style="width: 180px" /></td><td><select name="opt"><option>1</option><option>2</option></select></td></tr> <tr><td colspan="2" align="right"><input type="submit" id="search" value="search" /></td></tr> </table> </form> <iframe name="myiframe" style="width:550px; height:100px;"></iframe>    </body> </html> 

any body me....

here go:

the html + javascript: (index.php)

<form id="myform" >     <input type="text" name="first" value="22" />     <input type="text" name="second" value="" />     <input type="button" value="see result on iframe" onclick="iframeresults()" /> </form> <br/> <iframe src="#" name="results"></iframe>  <script type="text/javascript"> function iframeresults(){     var         form = document.getelementbyid("myform"),         first = form.elements.nameditem("first").value,         second = form.elements.nameditem("second").value;     if(first.length && second.length){         window.results.location.href='results.php?first=' + first + '&second=' + second;     }else{         alert('type text on 2 inputs before ;)');     } } </script> 

...and, finally...

the php: (results.php)

<?php if(isset($_get["first"]) && $_get["first"] != "" && isset($_get["second"]) && $_get["second"] != ""){     echo 'received:<br/>     first: '.$first.';<br/>     second: '.$second; }else{     echo 'error! type text on 2 inputs before. ;)'; } ?> 

font:

me

edit: does not work cross-origin framing ;)


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -