Click to See Complete Forum and Search --> : newbie help - create/display form on conditional


Bigjohn
11-25-2003, 08:14 AM
Hi all

I'm trying to let a variable value select what form is displayed.

<script language="javascript" type="text/javascript">
<!--
{
var p="$90.00"
if (p == '$90.00')
{
document.write(p)
<form action="https://xxx.xxx.xxx/cgi-bin/script" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="user" value="xxxxxxx">
<input type="hidden" name="item_name" value="item selected">
<input type="hidden" name="amount" value="90.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://xxx.xxx.xxx/button.gif
</form>
}

else if (p == '$130.00'){}

else if (p == '$165.00'){}

else if (p == '$175.00') {}

else
document.write("ERROR")
}


Now - the document.write(p) is to test that the variable is set.
After each ELSE IF i would have a variation of the form.
Tell me why this script does not work? Can you tell i'm a neophyte with Java?


John

ray326
11-25-2003, 10:27 AM
<form action="https://xxx.xxx.xxx/cgi-bin/script" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="user" value="xxxxxxx">
<input type="hidden" name="item_name" value="item selected">
<input type="hidden" name="amount" value="90.00">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="image" src="https://xxx.xxx.xxx/button.gif
</form>

That isn't Javascript.

Factor out all the common form bits and only use Javascript to emit things that are distinct for each condition.

Bigjohn
11-25-2003, 10:40 AM
So what you're saying is that I cannot 'create' a form within the conditional?

This is starting to sound harder than it should....

John