Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

random number script modification

Posted 27 Jan 2004 16:23:40
1
has voted
27 Jan 2004 16:23:40 sander kerstens posted:
hi scripters

i need this script to be modified so the random number value will be put in a hidden field called orderid
<%
Dim strrandom
Randomize
Random_Number_Min = 7825874
Random_Number_Max = 48798548789645
Random_Number = Int(((Random_Number_Max-Random_Number_Min+1) * Rnd) + Random_Number_Min)
Response.Write "Random Number = "& Random_Number &" <br>"
%>

i suppose the response.write needs to be replaced but have no clue with what..

thanks for youre time

greets Sander

Replies

Replied 27 Jan 2004 19:17:01
27 Jan 2004 19:17:01 Dan Berdusco replied:
You should be able to simply add a hidden form field like this:

<pre id=code><font face=courier size=2 id=code> &lt;input type="hidden" name="orderid" value="&lt;%= Random_Number %&gt;"&gt;</font id=code></pre id=code>

and if you don't want the random number to be displayed on the page, take out the the last line of the script:

<pre id=code><font face=courier size=2 id=code> &lt;%
Dim strrandom
Randomize
Random_Number_Min = 7825874
Random_Number_Max = 48798548789645
Random_Number = Int(((Random_Number_Max-Random_Number_Min+1) * Rnd) + Random_Number_Min)
%&gt;
</font id=code></pre id=code>

Replied 27 Jan 2004 19:32:22
27 Jan 2004 19:32:22 sander kerstens replied:
yep this works no i have another question what if i wanted to upload this value to the database with the insert record behavior...

i changed the hidden field to text but i does not appear in the insert record behavior dialog box...

thank for youre help so far
greetz Sander
Replied 27 Jan 2004 19:35:17
27 Jan 2004 19:35:17 Dan Berdusco replied:
Make sure that the hidden field is located between you opening and closing form tags.

Replied 27 Jan 2004 20:15:18
27 Jan 2004 20:15:18 sander kerstens replied:
this is the situation now what is wrong i can't seem to find it

this is a part of the total code

&lt;table width="449" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;!--DWLayoutTable--&gt;
&lt;tr&gt;
&lt;td width="449" height="421" valign="top"&gt;&lt;form name="form1" method="POST" action="&lt;%=MM_editAction%&gt;"&gt;
&lt;table width="200" border="1"&gt;
&lt;tr&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("naam".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("straat".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("postcode".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("woonplaats".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("telefoon".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("email".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;td&gt;&nbsp;&lt;/td&gt;
&lt;/tr&gt;

&lt;%
Dim strrandom
Randomize
Random_Number_Min = 7825874
Random_Number_Max = 48798548789645
Random_Number = Int(((Random_Number_Max-Random_Number_Min+1) * Rnd) + Random_Number_Min)
response.write "&lt;input type=""text"" name=""orderid"" value=""" & Random_Number & """&gt;"
%&gt;
&lt;/table&gt;

&lt;input name="textfield3" type="text" value="&lt;%= Request.Form("orderid" %&gt;"&gt;
&lt;input name="textfield" type="text" value="&lt;%=(klantzien.Fields.Item("klantid".Value)%&gt;"&gt;
&lt;input name="textfield2" type="text" value="&lt;%=(vestigin.Fields.Item("vestiging".Value)%&gt;"&gt;
&lt;input type="submit" name="Submit" value="Submit"&gt;
&lt;input type="hidden" name="MM_insert" value="form1"&gt;


&lt;/form&gt;
&lt;p&gt;&nbsp;&lt;/p&gt;
&lt;p&gt; &lt;br&gt;
&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

thanks
Replied 28 Jan 2004 19:03:40
28 Jan 2004 19:03:40 Dan Berdusco replied:
Try this instead:

<pre id=code><font face=courier size=2 id=code>&lt;table width="449" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;!--DWLayoutTable--&gt;
&lt;tr&gt;
&lt;td width="449" height="421" valign="top"&gt;&lt;form name="form1" method="POST" action="&lt;%=MM_editAction%&gt;"&gt;
&lt;table width="200" border="1"&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("naam".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("straat".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("postcode".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("woonplaats".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("telefoon".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("email".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;

&lt;%
Dim strrandom
Randomize
Random_Number_Min = 7825874
Random_Number_Max = 48798548789645
Random_Number = Int(((Random_Number_Max-Random_Number_Min+1) * Rnd) + Random_Number_Min)%&gt;
&lt;/table&gt;

&lt;input name="orderid" type="text" value="&lt;%= Random_Number %&gt;"&gt;
&lt;input name="textfield3" type="text" value="&lt;%= Request.Form("orderid" %&gt;"&gt;
&lt;input name="textfield" type="text" value="&lt;%=(klantzien.Fields.Item("klantid".Value)%&gt;"&gt;
&lt;input name="textfield2" type="text" value="&lt;%=(vestigin.Fields.Item("vestiging".Value)%&gt;"&gt;
&lt;input type="submit" name="Submit" value="Submit"&gt;
&lt;input type="hidden" name="MM_insert" value="form1"&gt;


&lt;/form&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;br&gt;
&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt; </font id=code></pre id=code>
Replied 28 Jan 2004 19:47:33
28 Jan 2004 19:47:33 sander kerstens replied:
yep this works thanks very much.....


Try this instead:

<pre id=code><font face=courier size=2 id=code>&lt;table width="449" border="0" cellpadding="0" cellspacing="0"&gt;
&lt;!--DWLayoutTable--&gt;
&lt;tr&gt;
&lt;td width="449" height="421" valign="top"&gt;&lt;form name="form1" method="POST" action="&lt;%=MM_editAction%&gt;"&gt;
&lt;table width="200" border="1"&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("naam".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("straat".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("postcode".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("woonplaats".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("telefoon".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(klantzien.Fields.Item("email".Value)%&gt;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt; &lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;

&lt;%
Dim strrandom
Randomize
Random_Number_Min = 7825874
Random_Number_Max = 48798548789645
Random_Number = Int(((Random_Number_Max-Random_Number_Min+1) * Rnd) + Random_Number_Min)%&gt;
&lt;/table&gt;

&lt;input name="orderid" type="text" value="&lt;%= Random_Number %&gt;"&gt;
&lt;input name="textfield3" type="text" value="&lt;%= Request.Form("orderid" %&gt;"&gt;
&lt;input name="textfield" type="text" value="&lt;%=(klantzien.Fields.Item("klantid".Value)%&gt;"&gt;
&lt;input name="textfield2" type="text" value="&lt;%=(vestigin.Fields.Item("vestiging".Value)%&gt;"&gt;
&lt;input type="submit" name="Submit" value="Submit"&gt;
&lt;input type="hidden" name="MM_insert" value="form1"&gt;


&lt;/form&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;br&gt;
&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt; </font id=code></pre id=code>

Reply to this topic