Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing selected value to append to action url

Status
Not open for further replies.

PushCode

Programmer
Joined
Dec 17, 2003
Messages
573
Location
US
Need help with this concept. User selects an option from a select box, then clicks the form button. Need to append the value of whichever option the user selects to the end of the action url.

I'm getting the following error: Object doesn't support this property or method

Any ideas? The code follows
Code:
<script>
	function doMat(idval)
		{
		document.frmMat.action="index.cfm?viewState=prodShow&matid="+idval
		document.frmMat.sumbit();
		}
</script>
<form name="frmMat" method="post">
		<td>
	    <select name="materials" class="onwhite">
		  <option class="onwhite">Select One...</option>
		  <option class="onwhite" value="all">All Materials</option>
		  <cfoutput query="get_materials">
		  <option class="onwhite" value="#material_id#">#material_name#</option>
		  </cfoutput>
		</select><input type="button" name="goMat" value="go" onclick="doMat('document.frmMat.materials.value');" class="gobtn">
		</td>
		</form>
 
try something like this:
Code:
document.frmMat.action [COLOR=red][b]+=[/b][/color] "?matid" + idval;

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Getting same error trying that method.

document.frmMat.action += "index.cfm?viewState=prodShow&matid" + idval;

Am I capturing and passing the select box value properly?
 
I don't know, I've never used coldfusion. However, if you'd like to test it out just put this as the first line of your function:
Code:
alert(idval);

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Forgot about the alert trick!

This is not a CF issue. The CF does work properly.

The alert value is showing up as: document.frmMat.materials.value

So I am not capturing/passing it correctly. Assume that the select value is a static number, b/c to the browser, that's what it is.
 
I see, change this:
Code:
onclick="doMat([COLOR=red][b]'[/b][/color]document.frmMat.materials.value[COLOR=red][b]'[/b][/color]);"
to this:
Code:
onclick="doMat(document.frmMat.materials.value);"

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Okay, now it's definetely passing the proper value to the script. However, I'm still getting the same error message.
'Object doesn't support this property or method'

Anyone see what's wrong here? Just can't find the code!

This has to be something simple. I know I've done this before.
Code:
unction doMat(idval)
		{
		document.frmMat.action += "index.cfm?viewState=prodShow&matid" + idval;
		//document.frmMat.action="index.cfm?viewState=prodShow&matid="+idval
		document.frmMat.sumbit();
		}
<form name="frmMat" method="post">
		<td>
	    <select name="materials" class="onwhite">
		  <option class="onwhite">Select One...</option>
		  <option class="onwhite" value="all">All Materials</option>
		  <cfoutput query="get_materials">
		  <option class="onwhite" value="#material_id#">#material_name#</option>
		  </cfoutput>
		</select><input type="button" name="goMat" value="go" onclick="doMat(document.frmMat.materials.value);" class="gobtn">
		</td>
		</form>
 
sorry, when I made the += suggestion earlier I thought you already had an action element defined in your form tag. Perhaps that's what the browser isn't liking? Rewrite your form tag like this:
Code:
<form name="frmMat" method="post" [COLOR=red][b]action="index.cfm?viewState=prodShow"[/b][/color]>
and your function like this:
Code:
function doMat(idval) {
   document.[COLOR=red][b]forms["frmMat"][/b][/color].action += [COLOR=red][b]"&matid" + idval[/b][/color];
   document.[COLOR=red][b]forms["frmMat"][/b][/color].su[COLOR=red][b]bm[/b][/color]it();
}

I notice you also misspelled submit, so I colored that as well.

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Damn misspellings!

Thanks kaht. I got it working with my original method, and of course correct spelling:

function doMat(idval)
{
document.frmMat.action="index.cfm?viewState=prodShow&matid="+idval;
document.frmMat.submit();
}

 
You're welcome

-kaht

...looks like you don't have a job, so why don't you get out there and feed Tina.
headbang.gif
[rockband]
headbang.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top