-
Is there any way to do this?
I have a text field asking for a search term and a drop down menu. The drop down menu will be say vbulletin forums and links directory. What i want is for the script to submit to search.php if forums are selected and search.cgi if links is selected. Does this make sense? There will also be hidden variables, it would be better if they could be associated with either one or other of the actions but it is not essential.
Any ideas on how to do this or do i need to have an intermediate script?
-
Chris this should get you going:
Code:
<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
<!--
function create_action() {
for (var i =0; i < selecter.options.length; i++) {
if (selecter.options[i].selected == true) {
var peeper = selecter.options[i].value;
}
}
if (peeper == 'forums') {
document.form1.action = 'search.php';
}
else {
document.form1.action = 'search.cgi';
}
document.form1.submit();
}
//-->
</script>
</head>
<body>
<form name="form1">
<select name="loc">
<option value="forums">Forums
<option value="links">Links
</select>
<input type="submit" nbame="submit" value="Submit" onClick="create_action();">
</form>
<script language="JavaScript">
<!--
var selecter = document.form1.loc;
//-->
</script>
</body>
</html>
-
thank you so much for that but i am having some problems:
first i get this javascript error:
line: 19
char: 3
Object does not support this property or method.
It still seems to work though.
but...
if i add a hidden variable to the form, instead of going to the script like it should it does c:// sort of thing, ie the bit from the script is lost. any ideas on that?
lastly, how would i get the method="GET" into the form?
sorry for so many questions, but thanks for all the help so far.
-
Change
Code:
<form name="form1">
to
Code:
<form name="form1" action="" method="GET">