Gamefreakjf11
05-29-2010, 02:46 AM
Hi, I'm a beginner coder. I only know a little javascript so I'd like to ask for some help. I'm trying to make a search page that searches a certain site depending on which button you press (like pressing the google button searches google). The only problem is I want all the buttons to use the same text field. I've tried so many different things but can't seem to get it to work. After googling it a few times and trying different things, this is the best I got:
<html>
<body>
<script language="JavaScript">
function OnSubmitForm()
{
if(document.pressed == 'Yahoo Search')
{
document.srchform.action ="http://search.yahoo.com/search?p=";
}
else
if(document.pressed == 'Google Search')
{
document.srchform.action ="http://www.google.com/search?q=";
}
return true;
}
</script>
<form name="srchform" onSubmit="return OnSubmitForm();">
<input type="text"size="30" maxlength="255" />
<input type="submit" onClick="document.pressed=this.value" value="Yahoo Search">
<input type="submit" onClick="document.pressed=this.value" value="Google
Search">
</form>
</body>
</html>
Can someone help me out?
<html>
<body>
<script language="JavaScript">
function OnSubmitForm()
{
if(document.pressed == 'Yahoo Search')
{
document.srchform.action ="http://search.yahoo.com/search?p=";
}
else
if(document.pressed == 'Google Search')
{
document.srchform.action ="http://www.google.com/search?q=";
}
return true;
}
</script>
<form name="srchform" onSubmit="return OnSubmitForm();">
<input type="text"size="30" maxlength="255" />
<input type="submit" onClick="document.pressed=this.value" value="Yahoo Search">
<input type="submit" onClick="document.pressed=this.value" value="Google
Search">
</form>
</body>
</html>
Can someone help me out?