0

Hi,

I have a form with various elements such as ids, location. I need to pass these values to a php file through a javascript function. Right now I am able to pass only ids.
The Form

<form action="display.php">
    <label>Your ID</label>
        <input type="text" id="ids" name="ids" value="">

    <label>Location</label>
        <select name="location" id="location">
            <option>City 1</option>
            <option>City 2</option>
            <option>City 3</option>
            <option>City 4</option>

    <label>Interest</label>
        <input type="checkbox" name="interest[]" value="Friends" />
        <input type="checkbox" name="interest[]" value="Books" />
        <input type="checkbox" name="interest[]" value="Music" />
        <input type="checkbox" name="interest[]" value="Debates" />

</form>

I am passing the values to the php files through javascript

function passvalues(url, boxid){
            var A = document.getElementById('ids').value; 
            url = url + "?ids=" + A;
            .......
            ........}

PHP File

    $ids=$_GET['ids'];

        echo $ids;
        echo "<br>";

How should I pass 'location' and 'Interest' values also to the php file?

I tried this :-

var B = document.getElementById('location').value; 
                url = url + "?ids=" + A;
                url = url + "?location=" + B;

if 12345 is the id this returns
12345?location=City1

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by jstfsklh211
0

just post your whole form to the php page
(add a submit button to your form and add method="post" to your form tag)

and then get the values from $_POST

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.