How to get the form value if the value have the & symbol inside

Discussion in 'Web Design, HTML And CSS' started by dormingo, Mar 3, 2006.

  1. dormingo

    dormingo New Member

    Joined:
    Mar 3, 2006
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hello buddy, I have a problem of passing the Value in HTML Form to the VB Script function.

    Like example: My Text1 value="1234&abc"

    when pass the Text1 value to the Function(Text1.value), The Value pass in it will be 1234.
    but the actual is 1234&abc. ( Client Side )

    How Should I solve this Problem.....? Thank you...

    The Source Code:
    <html>
    <form name="form1">
    <input type="text" name="refno" value="1234&abcde"><input type="button" value="Submit"onclick="CheckSubmit(document.form1.refno.value)">
    </form>
    </html>
    <script language="vbscript">
    function CheckSubmit(refno)

    document.write(refno) ' The result will be 1234 Only, not 1234&abcde

    end function
     
    Last edited: Mar 4, 2006
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Can you provide the complete code where this thing is happening.
     
  3. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    39
    Trophy Points:
    28
    The problem is not with the passing of the variable but its the problem with the printing of value in the document.

    Try doing this and all should be fine
    Code:
    document.write("<PRE>")
    document.write(refno) ' The result will be 1234&abcde and not 1234
    document.write("</PRE>")
    
    Happy coding.
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I never knew you have edited the post to include the Code. Making a new post sends an email to all the posters of the thread and so it helps evryone to reply. If you just edit the new post try posting a line like I have edited the tread to include the code so that everyone knows.

    Also yes you have the solution now probably.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice