944,179 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Marked Solved
  • Views: 7235
  • ASP RSS
You are currently viewing page 1 of this multi-page discussion thread
Nov 5th, 2007
0

parameter passing thru on click for different buttons

Expand Post »
Hi to all

am new to asp and am parcipating a project on asp in our company... here i got one prob that passing the parameter thru onclick.. i tried a lot but nothing materialize..

i have 5 buttons here.. for all buttons same function that i have to submit the form iprev.. here my prob is when i save parameter into a session variable its showing "type mismatch" when i call the function.. here i given my codes and function nooooo sub.. plz if u can guide me plzzzzzz

ASP Syntax (Toggle Plain Text)
  1. <input type="button" value="Upload" name="B1" onClick='uploadpicture("img1")'><br><br>
  2. <input type="button" value="Upload" name="B2" onClick='uploadpicture("img2")'><br><br>
  3. <input type="button" value="Upload" name="B3" onClick='uploadpicture("img3")'><br><br>
  4. <input type="button" value="Upload" name="B4" onClick='uploadpicture("img4")'><br><br>
  5. <input type="button" value="Upload" name="B5" onClick='uploadpicture("img5")'><br><br>
  6.  
  7. <script language="vbscript">
  8. Sub uploadpicture(imgno)
  9. Session("imagecap" & strSUnique) = imgno
  10. Document.iprev.submit()
  11. End Sub
  12. </script>
Similar Threads
Reputation Points: 12
Solved Threads: 4
Junior Poster in Training
anto_nee is offline Offline
76 posts
since Aug 2007
Nov 6th, 2007
0

Re: parameter passing thru on click for different buttons

your onClick commands should be equal to:

onClick="uploadpicture('img1')">
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Nov 6th, 2007
0

Re: parameter passing thru on click for different buttons

no am getting the value of imgno inside the function...
after that i cannot assign it to a session variable..
if its not possible is thr any other ways to pass the parameters.....(other than url querystring)
Reputation Points: 12
Solved Threads: 4
Junior Poster in Training
anto_nee is offline Offline
76 posts
since Aug 2007
Nov 6th, 2007
0

Re: parameter passing thru on click for different buttons

Then your session variable is not setting correctly. You should have no problem retrieving and setting that imgno. The problem happens when you set the name of the session variable. Do you have to have a unique string on it as each session is only used by one computer? Try removing the strSUnique OR try resetting the value of strSUnique inside your sub. I know by removing it, it will work. It may work if you redeclare the variable in your sub.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Nov 6th, 2007
0

Re: parameter passing thru on click for different buttons

but its showing session is not a keyword when i put it inside the sub or function which is inside the vbscript. but outside the vbscript its working.. and another thing after removing vbscript tag when i click the button it should call the function but its showing object expected which is that function... think i am totally confused............
Reputation Points: 12
Solved Threads: 4
Junior Poster in Training
anto_nee is offline Offline
76 posts
since Aug 2007
Nov 7th, 2007
0

Re: parameter passing thru on click for different buttons

ASP Syntax (Toggle Plain Text)
  1. <input type="button" value="Upload" name="B1" onclick='<% Session("imagecap" & strSUnique) = "1"%>;submit()'><br><br>
  2. <input type="button" value="Upload" name="B2" onclick='<% Session("imagecap" & strSUnique) = "2"%>;submit()'><br><br>
  3. <input type="button" value="Upload" name="B3" onclick='<% Session("imagecap" & strSUnique) = "3"%>;submit()'><br><br>
  4. <input type="button" value="Upload" name="B4" onclick='<% Session("imagecap" & strSUnique) = "4"%>;submit()'><br><br>
  5. <input type="button" value="Upload" name="B5" onclick='<% Session("imagecap" & strSUnique) = "5"%>;submit()'><br><br>

now i tried like this.. working but whatever button i clicked its returning the value "5" for session variable.. cannot understand... can u plzzzzz if u found any prob here plzzzzz let me know.. coz i already taken 3 days for this........ plzzzzzzzz
Reputation Points: 12
Solved Threads: 4
Junior Poster in Training
anto_nee is offline Offline
76 posts
since Aug 2007
Nov 8th, 2007
1

Re: parameter passing thru on click for different buttons

the reason why your last code isn't working like you thought is because you are calling the <% %> when the server runs the code. Therefore, you are essentially setting session("imagecap...) 5 times, with firs 1, then 2, then 3, and ending in 5. This is why it will always be 5. Sorry I missed this before, but vbscript does not set values without the "SET" before the word.

set Session("imagecap" & strSUnique) = "#"

Unfortunatley I don't believe this will work because vbscript does not work with sessions this way. Your only way to make it work is to put it all in a form and send it back to itself, or to the next page with hidden input fields. Do something like this below:
ASP Syntax (Toggle Plain Text)
  1. <input type="button" value="Upload" name="B1" onclick="this.form.sessionvalue.value='1';submit()"><br><br>
  2. <input type="button" value="Upload" name="B2" onclick="this.form.sessionvalue.value='1';submit()"><br><br>
  3. <input type="button" value="Upload" name="B3" onclick="this.form.sessionvalue.value='1';submit()"><br><br>
  4. <input type="button" value="Upload" name="B4" onclick"this.form.sessionvalue.value='1';submit()"><br><br>
  5. <input type="button" value="Upload" name="B5" onclick="this.form.sessionvalue.value='1';submit()" /><br><br><input type="hidden" id="sessionvalue" name="sessionvalue" value="" />
Now on your next page, just do the following:
ASP Syntax (Toggle Plain Text)
  1. Session("imgcap" & strSUnique) = request.form("sessionvalue")
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Nov 8th, 2007
0

Re: parameter passing thru on click for different buttons

oh and if the this.form.sessionvalue.value= does not work for you, use:
document.forms.formname.sessionvalue.value=
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Nov 8th, 2007
0

Re: parameter passing thru on click for different buttons

hei this is some good logic but not working..
here my hidden field doesnot accept the value i think..
i forgot to say another thing .. my form tag is..
ASP Syntax (Toggle Plain Text)
  1. <form enctype="multipart/form-data" action="admin_iupl.asp" method="post" name="iprev">
i will give u the complete form and the next page requirements also..

ASP Syntax (Toggle Plain Text)
  1. <form enctype="multipart/form-data" action="admin_iupl.asp" method="post" name="iprev">
  2.  
  3. <table>
  4. <div>
  5.  
  6. <th align="Right" width="20%" valign="top">
  7.  
  8. Caption Image<br>
  9.  
  10. <%If uploadpic then
  11. If Not uPA(0) = Empty then%>
  12. <img id="img1" height="100" width="100" src=<%=upload & uPA(0)%>><br><br>
  13. <%else%>
  14. <img id="img1" height="100" width="100" src="img/nopic.gif"><br><br>
  15. <%end if
  16. else%>
  17. <img id="img1" height="100" width="100" src="img/nopic.gif"><br><br>
  18. <%end if%>
  19.  
  20. <%If uploadpic then
  21. If Not uPA(1) = Empty Then%>
  22. <img id="img2" height="100" width="100" src=<%=upload & uPA(1)%>><br><br>
  23. <%Else%>
  24. <img id="img2" height="100" width="100" src="img/nopic.gif"><br><br>
  25. <%end if
  26. else%>
  27. <img id="img2" height="100" width="100" src="img/nopic.gif"><br><br>
  28. <%end if%>
  29.  
  30. <%If uploadpic then
  31. If Not uPA(2) = Empty Then%>
  32. <img id="img3" height="100" width="100" src=<%=upload & uPA(2)%>><br><br>
  33. <%else%>
  34. <img id="img3" height="100" width="100" src="img/nopic.gif"><br><br>
  35. <%end if
  36. else%>
  37. <img id="img3" height="100" width="100" src="img/nopic.gif"><br><br>
  38. <%end if%>
  39.  
  40. <%If uploadpic Then
  41. If Not uPA(3) = Empty Then%>
  42. <img id="img4" height="100" width="100" src=<%=upload & uPA(3)%>><br><br>
  43. <%else%>
  44. <img id="img4" height="100" width="100" src="img/nopic.gif"><br><br>
  45. <%end if
  46. else%>
  47. <img id="img4" height="100" width="100" src="img/nopic.gif"><br><br>
  48. <%end if%>
  49.  
  50. <%If uploadpic then
  51. If Not uPA(4) = Empty Then%>
  52. <img id="img5" height="100" width="100" src=<%=upload & uPA(4)%>>
  53. <%else%>
  54. <img id="img5" height="100" width="100" src="img/nopic.gif"><br><br>
  55. <%end if
  56. else%>
  57. <img id="img5" height="100" width="100" src="img/nopic.gif"><br><br>
  58. <%end if%>
  59.  
  60. </th>
  61. <th align="Left" width="80%" valign="top">
  62.  
  63. <br>
  64.  
  65. <textarea rows="4" cols="35" name="img1caption">Ad Description</textarea><br>
  66. <input name="selpic" type="file" id="imgbrowse1">
  67. <input type="button" value="Upload" name="B1" id="B1" onclick="this.form.sessionvalue.value='0';submit()"><br><br><br>
  68.  
  69. <textarea rows="4" cols="35" name="img2caption">Ad Or Image Description</textarea><br>
  70. <input name="selpic" type="file">
  71. <input type="button" value="Upload" name="B2" id="B2" onclick="this.form.sessionvalue.value='1';submit()"><br><br>
  72.  
  73. <textarea rows="4" cols="35" name="img3caption">Image Description</textarea><br>
  74. <input name="selpic" type="file">
  75. <input type="button" value="Upload" name="B3" id="B3" onclick="this.form.sessionvalue.value='2';submit()"><br><br>
  76.  
  77.  
  78. <textarea rows="4" cols="35" name="img4caption">Image Description</textarea><br>
  79. <input name="selpic" type="file">
  80. <input type="button" value="Upload" name="B4" id="B4" onclick="this.form.sessionvalue.value='3';submit()"><br><br><br>
  81.  
  82.  
  83. <textarea rows="4" cols="35" name="img5caption">Image Description</textarea><br>
  84. <input name="selpic" type="file">
  85. <input type="button" value="Upload" name="B5" id="B5" onclick="this.form.sessionvalue.value='4';submit()"><br><br>
  86.  
  87. <input type="hidden" id="sessionvalue" name="sessionvalue" value="">
  88. </th>
  89. </table>
  90. </form>

this is my form in one page and the continuing is next page..
ASP Syntax (Toggle Plain Text)
  1. Session("imgcap" & strSUnique) = request.form("sessionvalue")

i think my hidden field not taking the value............
Reputation Points: 12
Solved Threads: 4
Junior Poster in Training
anto_nee is offline Offline
76 posts
since Aug 2007
Nov 8th, 2007
0

Re: parameter passing thru on click for different buttons

another one thing....another form is here in this same page.. i forgot to tell this.. sorryyyyyyyyyyyy
Reputation Points: 12
Solved Threads: 4
Junior Poster in Training
anto_nee is offline Offline
76 posts
since Aug 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: help me please. i am making a login page..
Next Thread in ASP Forum Timeline: SQl Injection through ASP and MS SQl 2000





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC