Click to See Complete Forum and Search --> : calling a command with combined strings from drop down box


roblanning
12-06-2003, 11:54 AM
I would like to be able to use drop down boxes and take the values assigned by them to construct a character string to input into the form action code. This doesn't necessarily need to be done even remotely similar to the way i have started it... i assume that the gist of what i am attempting is understood and i'll do it anyway possible.

Example code:

<form method="post" action="<!--#ystore_order id="ITEM_ID_GOES_HERE" -->">

<p>

<select size="1" name="APP">

<option value="21-402">90-93 Acura Integra All</option>

<option value="21-401">94-01 Acura Integra Non VTEC</option>

</select>



<select size="1" name="COLOR">

<option value="b">Blue</option>

<option value="r">Red</option>

<option value="c">Clear</option>

<option value="p">Polished</option>

</select>


<input type="submit" value="Order">

</p>

</form>


So ideally I want the user to be able to select “90-93 Acura Integra All” then “Blue”…..so when that’s the case I need the APP and COLOR to be combined into “ITEM_ID_GOES_HERE” portion of the thing as “21-402b”. I really hope there is some way of doing this….and it seems like it would be really simple.

fredmv
12-06-2003, 11:59 AM
Triple posted.

http://forums.webdeveloper.com/showthread.php?s=&threadid=22976
http://forums.webdeveloper.com/showthread.php?s=&threadid=22975
http://forums.webdeveloper.com/showthread.php?s=&threadid=22974

roblanning
12-06-2003, 12:16 PM
its triple posted because i don't know if it will require javascript or just html... didn't know where to start. So relax.

TheBearMay
12-06-2003, 02:34 PM
Something like this?


...
var ActionCode;

function ProcessApp(form,whichDrop){
if (whichDrop == "A") ActionCode =+ form.APP.options[form.APP.selectedIndex].value;
if (whichDrop == "C") ActionCode += form.COLOR.options[form.COLOR.selectedIndex].value;

...
<select size="1" name="APP" onChange="ProcessAction(this.form,'A')">
...
<select size="1" name="COLOR" onChange="ProcessAction(this.form, 'C')">
...

roblanning
12-06-2003, 03:25 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script LANGUAGE="JavaScript">
var partnum;

function placeorder(FORM)
{
partnum = FORM.a.options[selectedIndex].value + FORM.b.options[selectedIndex].value;
<!--#ystore_order id=partnum-->;
}
</script>


<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<form method="post" name="form_1" action='javascript:placeorder("form_1");'>
<p>

<select size="1" type="text" name = "a">
<option value="21-402">90-93 Acura Integra All</option>
<option value="21-401">94-01 Acura Integra Non VTEC</option>
</select>&nbsp;&nbsp;&nbsp;

<select size="1" type="text" name= "b">
<option value="b">Blue</option>
<option value="r">Red</option>
<option value="c">Clear</option>
<option value="p">Polished</option>
</select>&nbsp;&nbsp;&nbsp;&nbsp;


<input type="submit" value="Order">

</p>
</form>


</body>
</html>


still can't get it to even remotely work

TheBearMay
12-06-2003, 05:17 PM
This should work:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script type="text/javascript">
var partnum;

function placeorder(FORM)
{
partnum = FORM.a.options[FORM.a.selectedIndex].value +
FORM.b.options[FORM.b.selectedIndex].value;
<!--#ystore_order id=partnum-->;
}
</script>


<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<form method="post" name="form_1" >
<p>

<select size="1" type="text" name = "a">
<option value="21-402">90-93 Acura Integra All</option>
<option value="21-401">94-01 Acura Integra Non VTEC</option>
</select>

<select size="1" type="text" name= "b">
<option value="b">Blue</option>
<option value="r">Red</option>
<option value="c">Clear</option>
<option value="p">Polished</option>
</select>


<input type="submit" value="Order" onclick="placeorder(this.form)">

</p>
</form>


</body>
</html>

roblanning
12-06-2003, 07:18 PM
Got it almost working!

<!--#ystore_order id=partnum-->; this part is causing errors.

This was originally in the "<form method="post" **action=here**>"

Its the command that adds an item to a shopping cart if using a yahoo store. I am not sure if it should be called from the function or if there is some way to call it in the html.

simpson97
12-07-2003, 05:26 PM
You might take a look at this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language='javascript' type='text/javascript'>
<!-- //
function submitForm(formObj) {
var urlExtension = 'cgi';
var product = formObj.products[formObj.products.selectedIndex].value;
var option = formObj.options[formObj.options.selectedIndex].value;
if(document.getElementById)
{
postUrl = product + '_' + option + '.' + urlExtension;
document.getElementById('form_id').setAttribute('action', postUrl);
document.new_browser.submit();
}
if(document.all)
{
var postUrl = '<form name=myform method=post action=' +
product + '_' + option + '.' + urlExtension + '>';
document.all.formHead.innerHTML = postUrl;
document.myform.submit();
}
}
// -->
</script>
</head>
<body>
<center>
<div id='formHead'><form id=form_id name=new_browser method=post action=placeholder.html></div>
<select name='products'>
<option value='product_0' selected>Product 0</option>
<option value='product_1'>Product 1</option>
<option value='product_2'>Product 2</option>
<option value='product_3'>Product 3</option>
</select>
<select name='options' selected>
<option value='option_0'>Option 0</option>
<option value='option_1'>Option 1</option>
<option value='option_2'>Option 2</option>
<option value='option_3'>Option 3</option>
</select>
<input type='button' value='Submit' onclick='submitForm(this.form)'>
</form>
<a href='mailto:simpson_97@yahoo.com'>Email author</a>
</center>
</body>
</html>



Bob

roblanning
12-07-2003, 05:47 PM
I got it working. Thank you for the help. My code did not turn out to be nearly as complicated as the code u guys presented me with, but i learned alot from the help provided. This was my first time ever dealing with javascript, let alone html. I ended up using alert() functions to figure out what exactly the <!--#ystore_order....yada yada--> was doing. And assumed that what i found had to be done using submit then ultimately left it up to the form. Just used the function to redefine the form.action.....makes sense i dont know why it took me so long to figure it out. It would have been alot easier if yahoo would have responded to my question about the <!--#ystore....--> code. Not sure if my method is a common one, but here is what i ended up with:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script LANGUAGE="JavaScript">
var partnum;

function placeorder(FORM)
{
alert("function called");
partnum = FORM.a.options[FORM.a.selectedIndex].value + FORM.b.options[FORM.b.selectedIndex].value;
alert(partnum);
FORM.action="http://order.store.yahoo.com/cgi-bin/wg-order?yhst-6253694447421+" + partnum;
alert(FORM.action);
}
</script>


<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>

<form method="post" name="FORM_1">
<p>

<select size="1" name = "a">
<option value="21-402">90-93 Acura Integra All</option>
<option value="21-401">94-01 Acura Integra Non VTEC</option>
</select>&nbsp;&nbsp;&nbsp;

<select size="1" name= "b">
<option value="b">Blue</option>
<option value="r">Red</option>
<option value="c">Clear</option>
<option value="p">Polished</option>
</select>&nbsp;&nbsp;&nbsp;&nbsp;


<input type="submit" value="Order" onClick='javascript:placeorder(FORM_1);'>

</p>
</form>



</body>
</html>


*******THANKS AGAIN FOR THE HELP!!!