Forum     

Go Back   Digit Technology Discussion Forum > Software > Programming
Register FAQ Calendar Mark Forums Read

Programming The destination for developers - C, C++, Java, Python and the lot


Closed Thread
 
LinkBack Thread Tools Display Modes
Old 24-11-2008, 08:23 PM   #1 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Javascript/VBscript hidden values & page redirect


I have a html form, where user makes a choice using drop-down menu. There are other elements in the form too. I use a vbscript to send the element values to my email.
Code:
<form name="test" method="post" action="cdosys.asp">
<input name="_recipients" type="hidden" value="mymail@myurl.com" />
<input name="_requiredFields" type="hidden"  value="name,email,country" />
<input name="_replyToField" type="hidden" value="email" />
<input name="_redirect" type="hidden" value="" />
This works when a predetermined value is entered. for eg. value="this.htm"
How do I place the value of input name (in red colour), depending on what the user chooses? What is the code?
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline  
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 24-11-2008, 08:52 PM   #2 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Javascript/VBscript hidden values & page redirect

Code:
<select id="ddbox" onchange="document.getElementById('redirect').value=this.value">
   <option value="location1.html">Location 1</option>
   <option value="location2.html">Location 2</option>
   <option value="location3.html">Location 3</option>
</select>
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 24-11-2008, 09:01 PM   #3 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Javascript/VBscript hidden values & page redirect

Thanks, but what should go into the value=""?
Code:
<input name="_redirect" type="hidden" value="" />
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline  
Old 24-11-2008, 09:05 PM   #4 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Javascript/VBscript hidden values & page redirect

^That will be dynamically decided, when the user makes a selection from the drop down.
Isn't that how you wanted it?
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 24-11-2008, 09:11 PM   #5 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Javascript/VBscript hidden values & page redirect

Yes, but you did not get my point. The code
Code:
onchange="document.getElementById('redirect').value=this.value"
places the value into the hidden element redirect.
But, the question is what should I mention in this line?
Code:
<input name="_redirect" type="hidden" value="" />
The code is not working, as the value is not specified here (value="")
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline  
Old 24-11-2008, 09:16 PM   #6 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Javascript/VBscript hidden values & page redirect

^That is because you have not declared the ID attribute in that element. Do it and it shall work.
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 24-11-2008, 09:23 PM   #7 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Javascript/VBscript hidden values & page redirect

I tried that too. Here is the code
Code:
<select size="1" name="choice" id="choice" onchange="document.getElementById('redirect').value=this.value">
what about this one? Should it be
Code:
<input name="_redirect" type="hidden"  />
or
<input name="_redirect" type="hidden"  value=""/>
Anyway, it does not work.

I tried another workaround.
Code:
<select size="1" name="choice" id="choice" onchange="goto()">
function goto(){
x1 = document.test.choice.selectedIndex; 
x2 = document.test.choice.options[x1].value;
document.getElementById('_redirect').value=x3;
}
This doesn't work too.

I guess, I am making a mistake here. You are probably referring to hidden element's id. I now corrected it to
Code:
<input name="_redirect" type="hidden" id="hid" />
and made correction here:
Code:
<select size="1" name="choice" id="choice" onchange="document.getElementById('hid').value=this.value">
yet, it doesn't work.
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com

Last edited by Sridhar_Rao; 24-11-2008 at 09:30 PM.
Sridhar_Rao is offline  
Old 24-11-2008, 09:34 PM   #8 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Javascript/VBscript hidden values & page redirect

^how are you confirming if it works or not?
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 24-11-2008, 09:35 PM   #9 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Javascript/VBscript hidden values & page redirect

The page is not getting redirected at all. Anything wrong with the code?
Code:
<input name="_redirect" type="hidden" id="hid" value="" />
<select size="1" name="choice" id="choice" onchange="goto()">
function goto(){
x1 = document.test.choice.selectedIndex; 
x2 = document.test.choice.options[x1].value;
document.getElementById('hid').value=x3;
}
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com

Last edited by Sridhar_Rao; 24-11-2008 at 09:42 PM.
Sridhar_Rao is offline  
Old 24-11-2008, 09:46 PM   #10 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Javascript/VBscript hidden values & page redirect

^Thats because nowhere you have used the code for redirection. You just said that you want the redirection value to be put in the hidden field.
Code:
window.location=document.getElementById('redirect').value;
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 24-11-2008, 09:51 PM   #11 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Javascript/VBscript hidden values & page redirect

<input name="_redirect" type="hidden" id="hid" value="" />

The VBScript handles this. I am sending all the parameters to cdosys.asp, which does all the redirection business. My interest is to get a value to this element.

If I enter anything for this value="abcd.htm", it works fine. I only have to give that value dynamically based on user selection.
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline  
Old 24-11-2008, 10:10 PM   #12 (permalink)
Broken In
 
Join Date: Aug 2008
Location: Mumbai, India
Posts: 169
Default Re: Javascript/VBscript hidden values & page redirect

^Your id="hid" should be id="redirect" for Rohans code to work.
Bandu is offline  
Old 24-11-2008, 10:15 PM   #13 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Javascript/VBscript hidden values & page redirect

That is not an issue, I have referred the same id in both places. I have used hid in the element as well as in the script.

Well, I got it working now. I had made a simple, but stupid mistake. I was passing the value by value and then trying to catch it by reference.
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com

Last edited by Sridhar_Rao; 24-11-2008 at 10:26 PM.
Sridhar_Rao is offline  
Old 24-11-2008, 10:21 PM   #14 (permalink)
हॉर्न ओके प्लीज़
 
victor_rambo's Avatar
 
Join Date: Sep 2007
Posts: 1,493
Default Re: Javascript/VBscript hidden values & page redirect

Oh, I forgot to tell you, I am posting in javascript, make sure to use its equivalent in VBscript, else it obviously wont work!
__________________
विक्टर रॅंबो - चाणकया प्रभावित व्यक्ति

गीक होना माँगता
victor_rambo is offline  
Old 24-11-2008, 10:28 PM   #15 (permalink)
In The Zone
 
Sridhar_Rao's Avatar
 
Join Date: Feb 2007
Posts: 353
Default Re: Javascript/VBscript hidden values & page redirect

No, your post was the right one. I messed it up due to my stupidity. Read above and you will know. All I had to in the javascript function was to add this line:
Code:
document.getElementById('hid').value=document.test.choice.value;
And it works. Thanks Rohan
__________________
Want to study M.Sc in any medical subjects? Read this www.microrao.com/msc.htm
Microx, a diagnostic microbiology laboratory software application www.labmicrox.com
Sridhar_Rao is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Certifications Values Plasma_Snake QnA (read only) 7 29-07-2008 12:22 PM
how to redirect 404 error page on my websit coolid30 QnA (read only) 2 15-04-2008 03:52 PM
Redirect to wrong web page! Help!! midhunmon Software Q&A 2 01-11-2007 09:18 AM
{Tutorial} Redirect your visitors without using JavaScript! The Unknown Tutorials 3 09-03-2007 12:03 PM
changing ram values vasanth_12345 QnA (read only) 6 06-03-2005 04:05 PM

 
Latest Threads
- by gforz
- by soumya
- by Sujeet
- by icebags
- by Charan

Advertisement




All times are GMT +5.5. The time now is 03:00 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2